protected void InitializeStorageContext(string storageAccountName)
        {
            // lookup storage account by name and retrieve key
            var storageService = this.StorageClient.StorageAccounts.Get(storageAccountName);

            if (storageService == null)
            {
                ThrowTerminatingError(new ErrorRecord(
                                          new Exception("ServiceExtensionCannotFindStorageAccountName"),
                                          string.Empty,
                                          ErrorCategory.InvalidData,
                                          null));
            }
            var storageKeys = this.StorageClient.StorageAccounts.GetKeys(storageService.StorageAccount.Name);

            if (storageKeys == null || storageKeys.PrimaryKey == null || storageKeys.SecondaryKey == null)
            {
                ThrowTerminatingError(new ErrorRecord(
                                          new Exception("ServiceExtensionCannotFindStorageAccountKey"),
                                          string.Empty,
                                          ErrorCategory.InvalidData,
                                          null));
            }
            string storageAccountKey = storageKeys.PrimaryKey != null ? storageKeys.PrimaryKey : storageKeys.SecondaryKey;

            // now that key has been retrieved, initialize context and return
            StorageCredentials  creds = new StorageCredentials(storageAccountName, storageAccountKey);
            CloudStorageAccount csa   = new WindowsAzure.Storage.CloudStorageAccount(creds, true);

            StorageContext = new AzureStorageContext(csa);
        }
        protected void InitializeStorageContext(string storageAccountName)
        {
            // lookup storage account by name and retrieve key 
            var storageService = this.StorageClient.StorageAccounts.Get(storageAccountName);
            if (storageService == null)
            {
                ThrowTerminatingError(new ErrorRecord(
                    new Exception("ServiceExtensionCannotFindStorageAccountName"),
                    string.Empty,
                    ErrorCategory.InvalidData,
                    null));
            }
            var storageKeys = this.StorageClient.StorageAccounts.GetKeys(storageService.StorageAccount.Name);
            if (storageKeys == null || storageKeys.PrimaryKey == null || storageKeys.SecondaryKey == null)
            {
                ThrowTerminatingError(new ErrorRecord(
                    new Exception("ServiceExtensionCannotFindStorageAccountKey"),
                    string.Empty,
                    ErrorCategory.InvalidData,
                    null));
            }
            string storageAccountKey = storageKeys.PrimaryKey != null ? storageKeys.PrimaryKey : storageKeys.SecondaryKey;

            // now that key has been retrieved, initialize context and return
            StorageCredentials creds = new StorageCredentials(storageAccountName, storageAccountKey);
            CloudStorageAccount csa = new WindowsAzure.Storage.CloudStorageAccount(creds, true);
            StorageContext = new AzureStorageContext(csa);
        }