public static void SetDefaultStorage() { if (!string.IsNullOrEmpty(GetDefaultStorage(CredentialHelper.DefaultStorageName, CredentialHelper.Location))) { defaultAzureSubscription = vmPowershellCmdlets.SetAzureSubscription(defaultAzureSubscription.SubscriptionName, CredentialHelper.DefaultStorageName); storageAccountKey = vmPowershellCmdlets.GetAzureStorageAccountKey(defaultAzureSubscription.CurrentStorageAccountName); Assert.AreEqual(defaultAzureSubscription.CurrentStorageAccountName, storageAccountKey.StorageAccountName); blobUrlRoot = (vmPowershellCmdlets.GetAzureStorageAccount(defaultAzureSubscription.CurrentStorageAccountName)[0].Endpoints.ToArray())[0]; } else { Console.WriteLine("Unable to get the default storege account"); } }
public void GetStorageKeysProcess() { Func <string, StorageService> func = null; StorageServiceKeyOperationContext storageServiceKeyOperationContext = null; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { GetAzureStorageKeyCommand getAzureStorageKeyCommand = this; if (func == null) { func = (string s) => base.Channel.GetStorageKeys(s, this.StorageAccountName); } StorageService storageService = ((CmdletBase <IServiceManagement>)getAzureStorageKeyCommand).RetryCall <StorageService>(func); if (storageService != null) { StorageServiceKeyOperationContext storageAccountName = new StorageServiceKeyOperationContext(); storageAccountName.StorageAccountName = this.StorageAccountName; storageAccountName.Primary = storageService.StorageServiceKeys.Primary; storageAccountName.Secondary = storageService.StorageServiceKeys.Secondary; storageServiceKeyOperationContext = storageAccountName; } Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); storageServiceKeyOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); storageServiceKeyOperationContext.set_OperationId(operation.OperationTrackingId); storageServiceKeyOperationContext.set_OperationStatus(operation.Status); base.WriteObject(storageServiceKeyOperationContext, true); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; if (communicationException as EndpointNotFoundException == null || base.IsVerbose()) { this.WriteErrorDetails(communicationException); } else { base.WriteObject(null); return; } } } }
protected static void DownloadVhds() { storageAccountKey = vmPowershellCmdlets.GetAzureStorageAccountKey(defaultAzureSubscription.CurrentStorageAccountName); foreach (var vhdFile in VhdFiles) { string vhdBlobLocation = string.Format("{0}{1}/{2}", blobUrlRoot, VhdFilesContainerName, vhdFile); var vhdLocalPath = new FileInfo(Directory.GetCurrentDirectory() + "\\" + vhdFile); if (!File.Exists(vhdLocalPath.FullName)) { // Set the source blob BlobHandle blobHandle = Utilities.GetBlobHandle(vhdBlobLocation, storageAccountKey.Primary); SaveVhd(blobHandle, vhdLocalPath, storageAccountKey.Primary); } } }
public void NewStorageKeyProcess() { Func <string, StorageService> func = null; StorageServiceKeyOperationContext storageServiceKeyOperationContext = null; RegenerateKeys regenerateKey = new RegenerateKeys(); regenerateKey.KeyType = this.KeyType; RegenerateKeys regenerateKey1 = regenerateKey; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { CmdletExtensions.WriteVerboseOutputForObject(this, regenerateKey1); NewAzureStorageKeyCommand newAzureStorageKeyCommand = this; if (func == null) { func = (string s) => base.Channel.RegenerateStorageServiceKeys(s, this.StorageAccountName, regenerateKey1); } StorageService storageService = ((CmdletBase <IServiceManagement>)newAzureStorageKeyCommand).RetryCall <StorageService>(func); if (storageService != null) { StorageServiceKeyOperationContext storageAccountName = new StorageServiceKeyOperationContext(); storageAccountName.StorageAccountName = this.StorageAccountName; storageAccountName.Primary = storageService.StorageServiceKeys.Primary; storageAccountName.Secondary = storageService.StorageServiceKeys.Secondary; storageServiceKeyOperationContext = storageAccountName; } Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); storageServiceKeyOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); storageServiceKeyOperationContext.set_OperationId(operation.OperationTrackingId); storageServiceKeyOperationContext.set_OperationStatus(operation.Status); base.WriteObject(storageServiceKeyOperationContext, true); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } }
public static void SetDefaultStorage() { if (!string.IsNullOrEmpty(GetDefaultStorage(CredentialHelper.DefaultStorageName, CredentialHelper.Location))) { defaultAzureSubscription = vmPowershellCmdlets.SetAzureSubscription(defaultAzureSubscription.SubscriptionName, CredentialHelper.DefaultStorageName); storageAccountKey = vmPowershellCmdlets.GetAzureStorageAccountKey(defaultAzureSubscription.CurrentStorageAccountName); Assert.AreEqual(defaultAzureSubscription.CurrentStorageAccountName, storageAccountKey.StorageAccountName); blobUrlRoot = (vmPowershellCmdlets.GetAzureStorageAccount(defaultAzureSubscription.CurrentStorageAccountName)[0].Endpoints.ToArray())[0]; } else { Console.WriteLine("Unable to get the default storege account"); } }
protected static void DownloadVhds() { storageAccountKey = vmPowershellCmdlets.GetAzureStorageAccountKey(defaultAzureSubscription.CurrentStorageAccountName); foreach (var vhdFile in VhdFiles) { string vhdBlobLocation = string.Format("{0}{1}/{2}", blobUrlRoot, VhdFilesContainerName, vhdFile); var vhdLocalPath = new FileInfo(Directory.GetCurrentDirectory() + "\\" + vhdFile); if (!File.Exists(vhdLocalPath.FullName)) { // Set the source blob BlobHandle blobHandle = Utilities.GetBlobHandle(vhdBlobLocation, storageAccountKey.Primary); SaveVhd(blobHandle, vhdLocalPath, storageAccountKey.Primary); } } }