gpt4 book ai didi

c# - 无法在Azure服务器上安装VHD驱动器

转载 作者:行者123 更新时间:2023-12-03 03:20:26 24 4
gpt4 key购买 nike

请帮助我。我正在编写以下代码来挂载 vhd 文件。但我无法安装它。它在本地工作正常,但当我将其部署在 azure 服务器上时,网络角色保持离线状态。我尝试删除下面的 foreach block ,但没有成功。但是当我删除代码“Global.driveLetter =drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);”时角色已在服务器上准备好。但我不能这样做,因为这是安装驱动器的关键语句。

会出现什么问题?

    private static void MountAzureDrive()
{
string connectionStringSettingName = "AzureConnectionString";
string azureDriveContainerName = "azuredrives";
string azureDrivePageBlobName = Guid.NewGuid().ToString("N").ToLowerInvariant();
string azureDriveCacheDirName = Path.Combine(Environment.CurrentDirectory, "cache");

CloudStorageAccount.SetConfigurationSettingPublisher((a, b) =>
{
b(RoleEnvironment.GetConfigurationSettingValue(connectionStringSettingName));
});

//CloudStorageAccount storageAccount=CloudStorageAccount.FromConfigurationSetting(connectionStringSettingName);
CloudStorageAccount storageAccount=CloudStorageAccount.DevelopmentStorageAccount;

LocalResource localCache=RoleEnvironment.GetLocalResource("InstanceDriveCache");
CloudDrive.InitializeCache(localCache.RootPath + "cache", localCache.MaximumSizeInMegabytes);

// Just checking: make sure the container exists
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
blobClient.GetContainerReference("drives").CreateIfNotExist();

// Create cloud drive
//WebRole.drive=storageAccount.CreateCloudDrive(blobClient.GetContainerReference("drives").GetPageBlobReference("Test.VHD").Uri.ToString());
WebRole.drive = storageAccount.CreateCloudDrive("drives/Test.VHD");

try
{
WebRole.drive.CreateIfNotExist(512);
}
catch (CloudDriveException ex)
{
// handle exception here
// exception is also thrown if all is well but the drive already exists
}

foreach (var d in CloudDrive.GetMountedDrives())
{
var mountedDrive = storageAccount.CreateCloudDrive(d.Value.PathAndQuery);
mountedDrive.Unmount();
}
//Global.driveLetter = drive.Mount(25, DriveMountOptions.Force);
Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);
}

提前致谢。

最佳答案

也许这是显而易见的,但是...当您部署到 Windows Azure 时,您是否从开发存储更改了存储帐户?您已对开发存储模拟器进行了硬编码:

CloudStorageAccount storageAccount=CloudStorageAccount.DevelopmentStorageAccount;

关于c# - 无法在Azure服务器上安装VHD驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10009286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com