/// <summary> /// Creates a new storage account given a name and location /// </summary> public void CreateNewStorageAccount(string name, string location = LocationConstants.NorthEurope , StorageManagementOptions options = null) { if (options == null) { options = StorageManagementOptions.GetDefaultOptions; } // issue the create storage account command var create = new CreateStorageAccountCommand(name, "Created with Fluent Management", options, location) { SubscriptionId = SubscriptionId, Certificate = ManagementCertificate }; create.Execute(); var status = StorageStatus.Creating; while (status != StorageStatus.Created) { var command = new GetStorageAccountStatusCommand(name) { SubscriptionId = SubscriptionId, Certificate = ManagementCertificate }; command.Execute(); status = command.Status; } }
internal CreateStorageAccountCommand(string name, string description, StorageManagementOptions options, string location = LocationConstants.NorthEurope ) { Name = name.ToLower(); Description = description; Location = location; HttpVerb = HttpVerbPost; ServiceType = "services"; OperationId = "storageservices"; StorageOptions = options; }
/// <summary> /// Create the storage account if an account by the same name doesn't exist /// </summary> public void CreateStorageAccountIfNotExists(string name, string location = LocationConstants.NorthEurope, StorageManagementOptions options = null) { if (GetStorageAccountList().All(a => a.Name != name)) { CreateNewStorageAccount(name, location); } }