Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active December 5, 2022 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/a22207a421687e48f91fdf4421601a31 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/a22207a421687e48f91fdf4421601a31 to your computer and use it in GitHub Desktop.
Azure Bicep - Conditional Logic to deploy the storage account
@description('Environment name')
@allowed([
'featurebranch'
'dev'
'test'
'uat'
'production'
])
param environmentName string = 'dev'
var createStorageAccount = environmentName != 'featurebranch'
@description('Storage Account type')
@allowed([
'Premium_LRS'
'Premium_ZRS'
'Standard_GRS'
'Standard_GZRS'
'Standard_LRS'
'Standard_RAGRS'
'Standard_RAGZRS'
'Standard_ZRS'
])
param storageAccountType string = 'Standard_LRS'
@description('Location for the storage account.')
param location string = resourceGroup().location
@description('The name of the Storage Account')
param storageAccountName string = 'storageaccount1'
// if createStorageAccount is true, then only the storage account is created.
resource sa 'Microsoft.Storage/storageAccounts@2021-06-01' = if (createStorageAccount) {
name: storageAccountName
location: location
sku: {
name: storageAccountType
}
kind: 'StorageV2'
properties: {}
}
output storageAccountName string = storageAccountName
output storageAccountId string = sa.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment