.withRegion(location) .withExistingResourceGroup(resourceGroupName) .withSku(SkuName.fromString(targetStorageAccountType)) .create();
public static StorageAccount createStorageAccount(String subscriptionId, String name, String region, boolean newResourceGroup, String resourceGroup, Kind kind, AccessTier accessTier, boolean enableEncription, String skuName) throws Exception { AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager(); Azure azure = azureManager.getAzure(subscriptionId); StorageAccount.DefinitionStages.WithGroup newStorageAccountBlank = azure.storageAccounts().define(name).withRegion(region); StorageAccount.DefinitionStages.WithCreate newStorageAccountWithGroup; if (newResourceGroup) { newStorageAccountWithGroup = newStorageAccountBlank.withNewResourceGroup(resourceGroup); } else { newStorageAccountWithGroup = newStorageAccountBlank.withExistingResourceGroup(resourceGroup); } switch (kind) { case STORAGE: newStorageAccountWithGroup = newStorageAccountWithGroup.withGeneralPurposeAccountKind(); break; case STORAGE_V2: newStorageAccountWithGroup = newStorageAccountWithGroup.withGeneralPurposeAccountKindV2(); break; case BLOB_STORAGE: newStorageAccountWithGroup = newStorageAccountWithGroup.withBlobStorageAccountKind().withAccessTier(accessTier); break; default: throw new Exception("Unknown Storage Account Kind:" + kind.toString()); } if (enableEncription) { newStorageAccountWithGroup = newStorageAccountWithGroup.withBlobEncryption(); } return newStorageAccountWithGroup.withSku(StorageAccountSkuType.fromSkuName(SkuName.fromString(skuName))).create(); }
newAccount.withGeneralPurposeAccountKind().withSku(SkuName.fromString(newStorageAccount.getType())); withCreate = withCreate.withNewStorageAccount(newAccount); } else {
@Override public FunctionAppImpl withNewStorageAccount(String name, SkuName sku) { StorageAccount.DefinitionStages.WithGroup storageDefine = manager().storageManager().storageAccounts() .define(name) .withRegion(regionName()); if (super.creatableGroup != null && isInCreateMode()) { storageAccountCreatable = storageDefine.withNewResourceGroup(super.creatableGroup) .withGeneralPurposeAccountKind() .withSku(sku); } else { storageAccountCreatable = storageDefine.withExistingResourceGroup(resourceGroupName()) .withGeneralPurposeAccountKind() .withSku(sku); } this.addDependency(storageAccountCreatable); return this; }