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;
                    }
                }
            }
        }
Exemple #2
0
        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);
                }
            }
        }