コード例 #1
0
        protected override void OnProcessRecord()
        {
            var regenerateKeys = new StorageAccountRegenerateKeysParameters
            {
                Name = this.StorageAccountName,
                KeyType = string.IsNullOrEmpty(this.KeyType) ? StorageKeyType.Primary : (StorageKeyType)Enum.Parse(typeof(StorageKeyType), this.KeyType, true)
            };

            ExecuteClientActionNewSM(
                regenerateKeys,
                this.CommandRuntime.ToString(),
                () => this.StorageClient.StorageAccounts.RegenerateKeys(regenerateKeys),
                (s, r) =>
                {
                    return new StorageServiceKeyOperationContext
                    {
                        StorageAccountName = this.StorageAccountName,
                        Primary = r.PrimaryKey,
                        Secondary = r.SecondaryKey,
                        OperationDescription = this.CommandRuntime.ToString(),
                        OperationId = s.Id,
                        OperationStatus = s.Status.ToString()
                    };
                });
        }
 /// <summary>
 /// The Regenerate Keys operation regenerates the primary or secondary
 /// access key for the specified storage account.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460795.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Storage.IStorageAccountOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Regenerate Keys operation.
 /// </param>
 /// <returns>
 /// The primary and secondary access keys for a storage account.
 /// </returns>
 public static Task<StorageAccountRegenerateKeysResponse> RegenerateKeysAsync(this IStorageAccountOperations operations, StorageAccountRegenerateKeysParameters parameters)
 {
     return operations.RegenerateKeysAsync(parameters, CancellationToken.None);
 }
 /// <summary>
 /// The Regenerate Keys operation regenerates the primary or secondary
 /// access key for the specified storage account.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460795.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Storage.IStorageAccountOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Regenerate Keys operation.
 /// </param>
 /// <returns>
 /// The primary and secondary access keys for a storage account.
 /// </returns>
 public static StorageAccountRegenerateKeysResponse RegenerateKeys(this IStorageAccountOperations operations, StorageAccountRegenerateKeysParameters parameters)
 {
     return Task.Factory.StartNew((object s) =>
     {
         return ((IStorageAccountOperations)s).RegenerateKeysAsync(parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
コード例 #4
0
 /// <summary>
 /// The Regenerate Keys operation regenerates the primary or secondary
 /// access key for the specified storage account.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/ee460795.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Storage.IStorageAccountOperations.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Regenerate Keys operation.
 /// </param>
 /// <returns>
 /// The primary and secondary access keys for a storage account.
 /// </returns>
 public static StorageAccountRegenerateKeysResponse RegenerateKeys(this IStorageAccountOperations operations, StorageAccountRegenerateKeysParameters parameters)
 {
     try
     {
         return operations.RegenerateKeysAsync(parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
コード例 #5
0
        internal void RegenerateKeys()
        {
            StorageAccountRegenerateKeysParameters kp = new StorageAccountRegenerateKeysParameters();
            kp.KeyType = StorageKeyType.Primary;
            kp.Name = _parameters.StorageAccountName;

            _storageManagementClient.StorageAccounts.RegenerateKeys(kp);
        }