2012-04-04 9 views
1

zu mounten Bitte helfen Sie mir. Ich schreibe folgenden Code, um die VHD-Datei zu mounten. Aber ich kann es nicht montieren. Es funktioniert gut lokal, aber wenn ich es auf azure Server bereitstellen, bleibt die Webrole offline. Ich versuchte, indem ich foreach Block unten aber vergeblich entfernte. Aber wenn ich den Code "Global.driveLetter = drive.Mount (localCache.MaximumSizeInMegabytes - 20, DriveMountOptions.Force) entfernt habe;" Rolle wurde auf dem Server bereit. Aber ich kann das nicht tun, weil dies die Schlüsselaussage ist, um das Laufwerk zu mounten.Nicht in der Lage, VHD-Laufwerk auf Azure-Server

Was wäre das Problem?

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

Vielen Dank im Voraus.

+0

ich versuchen würde, das Ganze in einem try/catch setzen und sehen, ob etwas passiert. Oder melden Sie sich bei der Instanz an und debuggen Sie sie. Wenn Sie VS Ultimate verwenden, verwenden Sie IntelliTrace. – Tom

Antwort

1

Vielleicht ist dies offensichtlich, aber ... haben Sie bei der Bereitstellung in Windows Azure das Speicherkonto vom Dev-Speicher geändert? Sie haben die Entwickler Speicher Emulator hartcodiert:

CloudStorageAccount storageAccount=CloudStorageAccount.DevelopmentStorageAccount;