/// <summary> /// /// </summary> /// <param name="accountName"></param> /// <param name="accountKey"></param> /// <param name="azureDriveContainerName"></param> /// <param name="azureDrivePageBlobName"></param> /// <param name="?"></param> /// <returns></returns> public static string SnapshotAzureDrive(string accountName, string accountKey, string azureDriveContainerName, string azureDrivePageBlobName) { try { CloudStorageAccount csa = WAStorageHelper.GetCloudStorageAccount(accountName, accountKey, false); // Create the blob client CloudBlobClient client = csa.CreateCloudBlobClient(); // Create the blob container which will contain the pageblob corresponding to the azure drive. CloudBlobContainer container = client.GetContainerReference(azureDriveContainerName); container.CreateIfNotExist(); // Get the page blob reference which will be used by the azure drive. CloudPageBlob blob = container.GetPageBlobReference(azureDrivePageBlobName); CloudDrive drive = new CloudDrive(blob.Uri, csa.Credentials); if (drive != null) { return(drive.Snapshot().ToString()); } } catch (Exception ex) { WindowsAzureSystemHelper.LogError(String.Format("Error in snapshot drive {0} - {1}", azureDrivePageBlobName, ex.Message)); } return(string.Empty); }
/// <summary> /// Snapshot the specified drive /// </summary> /// <param name="drive"></param> public static string SnapshotAzureDrive(CloudDrive drive) { try { if (drive != null) { return(drive.Snapshot().ToString()); } } catch (Exception ex) { WindowsAzureSystemHelper.LogError(String.Format("Error in shapshot drive {0} ", ex.Message)); } return(string.Empty); }
/// <summary> /// Snapshot the drive /// </summary> /// <param name="accountName"></param> /// <param name="accountKey"></param> /// <param name="uriString"></param> public static string SnapshotAzureDrive(string accountName, string accountKey, string uriString) { try { CloudStorageAccount csa = WAStorageHelper.GetCloudStorageAccount(accountName, accountKey, false); CloudDrive drive = new CloudDrive(new Uri(uriString), csa.Credentials); if (drive != null) { return(drive.Snapshot().ToString()); } } catch (Exception ex) { WindowsAzureSystemHelper.LogError(String.Format("Error in snapshot drive with Uri {0} - {1}", uriString, ex.Message)); } return(string.Empty); }