VHD装服务器系统没驱动,无法在Azure服务器上安装VHD驱动器

代码尝试在Azure服务器上挂载VHD文件作为云驱动器,但在部署到WebRole时遇到问题,导致角色脱机。当尝试删除特定的驱动器挂载代码时,角色可以启动,但无法完成驱动器安装。问题可能涉及到权限、配置或资源管理。建议使用try/catch块进行调试或直接登录服务器进行检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

请帮助我。我正在编写以下代码来挂载vhd文件。但我无法安装它。它在本地很好地工作,但是当我将它部署在Azure服务器上时,webrole仍处于脱机状态。我尝试删除下面的foreach块但徒劳无功。但是当我删除代码“Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20,DriveMountOptions.Force);”角色已准备好在服务器上。但我不能这样做,因为这是安装驱动器的关键声明。无法在Azure服务器上安装VHD驱动器

会出现什么问题?

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);

}

在此先感谢。

+0

我会尝试把整个事情在一个try/catch,看看是否有事情发生。或登录到实例并调试它。如果您有VS Ultimate,请使用IntelliTrace。 –

2012-04-04 18:19:09

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值