public AppyPlayAzureConfigurationBuilder WithStorageAccount(string accountName, Region accountRegion) { var rgName = _infraParameters.ResourceGroupParameters.ResourceGroupName; var parameters = new AppyStorageParameters { ResourceGroupName = rgName, AccountName = accountName, AccountRegion = accountRegion }; _infraParameters.StorageAccountParameters = parameters; return(this); }
public static async Task CreateStorageAccountIfNotExists(this IAzure azure, ILogger logger, AppyStorageParameters parameters) { logger.Info($"Creating storage account with name {parameters.AccountName} in group {parameters.ResourceGroupName}"); var storageResource = await azure.StorageAccounts.GetByResourceGroupAsync(parameters.ResourceGroupName, parameters.AccountName); if (!ReferenceEquals(storageResource, null)) { logger.Info($"Storage Account with name {parameters.AccountName} already exists in group {parameters.ResourceGroupName}"); return; } await azure.StorageAccounts .Define(parameters.AccountName) .WithRegion(parameters.AccountRegion) .WithExistingResourceGroup(parameters.ResourceGroupName) .WithGeneralPurposeAccountKind() .CreateAsync(); logger.Info($"Created storage account with name {parameters.AccountName} in group {parameters.ResourceGroupName}"); }
public static async Task DeleteStorageAccountIfExists(this IAzure azure, ILogger logger, AppyStorageParameters parameters) { logger.Info($"Deleting storage account with name {parameters.AccountName} in group {parameters.ResourceGroupName}"); var storageResource = await azure.StorageAccounts.GetByResourceGroupAsync(parameters.ResourceGroupName, parameters.AccountName); if (ReferenceEquals(storageResource, null)) { logger.Info($"Storage Account with name {parameters.AccountName} not exists in group {parameters.ResourceGroupName}"); return; } await azure.ResourceGroups.DeleteByNameAsync(parameters.ResourceGroupName); logger.Info($"Deleted resource group with name {parameters.ResourceGroupName}"); }