Problem in Mounting the VHD drive
-
4 апреля 2012 г. 7:20
Hi all,
Please help me. I am writing following code to mount the vhd file. But I am not able to mount it. It works fine locally but when I deploy it on azure server the webrole remains offline. I tried by removing foreach block below but in vain. But when I removed the code "Global.driveLetter = drive.Mount(localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force);" with foreach block, role got ready on server. But I can't do this because this is the key statement to mount the drive.
I am uploading my VHD using "Cloud Storage Studio".
What would be the problem?
private static void MountAzureDrive()
Thanks in advance.
{
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);
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);
}
- Изменено BhimrajG 4 апреля 2012 г. 7:21 Updated
Все ответы
-
4 апреля 2012 г. 9:36Модератор
Hi,
According to your description, you have mounted the Drive in local, do you ever umount it before running on the cloud? As far as i know, every drive can only mount once (Access write), so please make sure it was unmounted before running.
Hope it can help you.
Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
-
4 апреля 2012 г. 9:57
I have written code in onstop event to unmount the drive. Also for local I am using
storageAccount=CloudStorageAccount.DevelopmentStorageAccount;
For server I am using the code
storageAccount=CloudStorageAccount.FromConfigurationSetting(connectionStringSettingName);
So there will not be any problem which you mentioned in the post.
Yes, I am unmounting the VHD drive in onstop event of webrole
- Изменено BhimrajG 4 апреля 2012 г. 10:00 updated
-
5 апреля 2012 г. 2:59Модератор
Hi,
It seems a strange problem, please try to open Trace to see more details about your exception and post here.
Thank you.
Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
-
21 мая 2012 г. 6:49Hi - was this ever resolved? let us know if you still need help with this issue.
-Jeff

