/// <summary> /// Method to submit the request to create new storage account and return request token. /// </summary> /// <param name="subscriptionId">Subscription id</param> /// <param name="cert">Auth certificate</param> /// <param name="input">Input required to create new storage acc</param> /// <returns>Token to track the progress of storage account creation</returns> public static string CreateStorageAcc(string subscriptionId, CreateStorageServiceInput input, X509Certificate2 cert) { ClientOutputMessageInspector messageInspector; IServiceManagement serviceManager = ServiceInitializer.Get(cert, out messageInspector); serviceManager.CreateStorageAccount(subscriptionId, input); return messageInspector.ResponseMessage.Headers["x-ms-request-id"]; }
/// <summary> /// Method to submit the request to create new storage account and return request token. /// </summary> /// <param name="subscriptionId">Subscription id</param> /// <param name="cert">Auth certificate</param> /// <param name="input">Input required to create new storage acc</param> /// <returns>Token to track the progress of storage account creation</returns> public static string CreateStorageAcc(string subscriptionId, CreateStorageServiceInput input, X509Certificate2 cert) { ClientOutputMessageInspector messageInspector; IServiceManagement serviceManager = ServiceInitializer.Get(cert, out messageInspector); serviceManager.CreateStorageAccount(subscriptionId, input); return(messageInspector.ResponseMessage.Headers["x-ms-request-id"]); }
private void CreateStorageAccount() { WriteObject("Creating storage account: " + _storageAccount); WriteObject("This may take a few minutes."); CreateStorageServiceInput input = new CreateStorageServiceInput(); input.ServiceName = this.StorageAccount; input.Label = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(this.StorageAccount)); if (string.IsNullOrEmpty(this.Location) == false) { input.Location = this.Location; } else if (string.IsNullOrEmpty(this.AffinityGroup) == false) { input.AffinityGroup = this.AffinityGroup; } else // Randomly use "North Central US" or "South Central US" { int randomLocation = new Random().Next(0, 1); input.Location = randomLocation == 0 ? "North Central US" : "South Central US"; } try { _createRequestToken = ServiceManagementHelpers.CreateStorageAcc(this._subscriptionId, input, this._cert); } catch (Exception) { if (IsStorageAccountLimitExceeded() == true) { throw new ApplicationFailedException(Resources.StorageAccLimitReached); } else { throw; } } WaitTillCreationComplete(); }