/// <summary> /// The Update Storage Account operation updates the label and the /// description, and enables or disables the geo-replication status /// for a storage account in Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/hh264516.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Storage.IStorageAccountOperations. /// </param> /// <param name='accountName'> /// Required. Name of the storage account to update. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Update Storage Account /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task<AzureOperationResponse> UpdateAsync(this IStorageAccountOperations operations, string accountName, StorageAccountUpdateParameters parameters) { return operations.UpdateAsync(accountName, parameters, CancellationToken.None); }
public void CanCreateUpdateGetAndDeleteStorageAccounts() { TestLogTracingInterceptor.Current.Start(); using (var undoContext = UndoContext.Current) { undoContext.Start(); var mgmt = TestBase.GetServiceClient<ManagementClient>(); var storage = TestBase.GetServiceClient<StorageManagementClient>(); try { var location = mgmt.GetDefaultLocation("Storage"); const string westUS = "West US"; if (mgmt.Locations.List().Any( c => string.Equals(c.Name, westUS, StringComparison.OrdinalIgnoreCase))) { location = westUS; } var storageAccountName = HttpMockServer.GetAssetName( "teststorage1234", "teststorage").ToLower(); Assert.True(storage.StorageAccounts .CheckNameAvailability(storageAccountName).IsAvailable); // Create var storageCreateParams = new StorageAccountCreateParameters { Location = location, AffinityGroup = null, Label = "Test测试1", Description = "Test测试2", Name = storageAccountName, AccountType = StorageAccountTypes.StandardGRS, ExtendedProperties = new Dictionary<string, string> { { "foo1", "bar" }, { "foo2", "baz" } } }; var st1 = storage.StorageAccounts.Create(storageCreateParams); // Get var storageCreated = storage.StorageAccounts .Get(storageAccountName).StorageAccount; VerifyStorageAccount( storageCreated, storageCreateParams.Name, storageCreateParams.Label, storageCreateParams.Description, storageCreateParams.Location, storageCreateParams.AccountType); Assert.True(storageCreated.ExtendedProperties["foo1"] == "bar"); Assert.True(storageCreated.ExtendedProperties["foo2"] == "baz"); // Update var storageUpdateParams = new StorageAccountUpdateParameters { Label = "Test测试3", Description = "Test测试4", AccountType = StorageAccountTypes.StandardRAGRS }; var st2 = storage.StorageAccounts.Update( storageAccountName, storageUpdateParams); // List var storageUpdated = storage.StorageAccounts.List() .First(s => s.Name == storageAccountName); VerifyStorageAccount( storageUpdated, storageAccountName, storageUpdateParams.Label, storageUpdateParams.Description, storageCreateParams.Location, storageUpdateParams.AccountType); // Keys var st3 = storage.StorageAccounts.GetKeys(storageAccountName); var st4 = storage.StorageAccounts.RegenerateKeys( new StorageAccountRegenerateKeysParameters { Name = storageAccountName, KeyType = StorageKeyType.Primary }); var st5 = storage.StorageAccounts.GetKeys(storageAccountName); Assert.True(st5.PrimaryKey != st3.PrimaryKey && st5.SecondaryKey == st3.SecondaryKey); // Delete var st6 = storage.StorageAccounts.Delete(storageAccountName); Assert.True(!storage.StorageAccounts.List() .StorageAccounts.Any(s => s.Name == storageAccountName)); } finally { undoContext.Dispose(); mgmt.Dispose(); storage.Dispose(); TestLogTracingInterceptor.Current.Stop(); } } }
/// <summary> /// The Update Storage Account operation updates the label and the /// description, and enables or disables the geo-replication status /// for a storage account in Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/hh264516.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Storage.IStorageAccountOperations. /// </param> /// <param name='accountName'> /// Required. Name of the storage account to update. /// </param> /// <param name='parameters'> /// Required. Parameters supplied to the Update Storage Account /// operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static AzureOperationResponse Update(this IStorageAccountOperations operations, string accountName, StorageAccountUpdateParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IStorageAccountOperations)s).UpdateAsync(accountName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// The Update Storage Account operation updates the label, the /// description, and enables or disables the geo-replication status /// for a storage account in Windows Azure. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/hh264516.aspx /// for more information) /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Storage.IStorageAccountOperations. /// </param> /// <param name='serviceName'> /// Name of the storage account to update. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Storage Account operation. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static OperationResponse Update(this IStorageAccountOperations operations, string serviceName, StorageAccountUpdateParameters parameters) { try { return operations.UpdateAsync(serviceName, parameters).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
public void SetStorageAccountProcess() { if (string.Equals(this.ParameterSetName, GeoReplicationEnabledParamSet)) { WriteWarning(Resources.DeprecationOfTheGeoReplicationEnabledParamInTheSetCmdlet); } var upstorageinput = new StorageAccountUpdateParameters { AccountType = GeoReplicationEnabled.HasValue && GeoReplicationEnabled.Value ? StorageAccountTypes.StandardGRS : this.Type, Description = this.Description, Label = this.Label }; ExecuteClientActionNewSM( upstorageinput, CommandRuntime.ToString(), () => this.StorageClient.StorageAccounts.Update(this.StorageAccountName, upstorageinput)); }
/// <summary> /// Update storage service /// </summary> /// <param name="storageServiceName"></param> /// <param name="input"></param> public void UpdateStorageService(string storageServiceName, StorageAccountUpdateParameters input) { TestEasyLog.Instance.Info(string.Format("Updating storage service '{0}'", storageServiceName)); StorageManagementClient.StorageAccounts.UpdateAsync(storageServiceName, input, new CancellationToken()).Wait(); }
internal void UpdateStorageAccount(string Description, string Label, string AccountType) { var parms = new StorageAccountUpdateParameters(); parms.Description = Description; parms.Label = Label; parms.AccountType = AccountType; _storageManagementClient.StorageAccounts.Update( _parameters.StorageAccountName, parms); }