Skip to content

Instantly share code, notes, and snippets.

@ThomasPe
Last active July 31, 2023 10:56
Show Gist options
  • Save ThomasPe/4d0ca0fba238a9399342340d11fa4d34 to your computer and use it in GitHub Desktop.
Save ThomasPe/4d0ca0fba238a9399342340d11fa4d34 to your computer and use it in GitHub Desktop.
Azure Bicep elseif
param stage string = 'prod'
var isProd = stage == 'prod'
var isTest = stage == 'test'
var isDev = stage == 'dev'
resource saProd 'Microsoft.Storage/storageAccounts@2022-09-01' existing = if (isProd) {
name: 'prodstorageaccounttp'
}
resource saTest 'Microsoft.Storage/storageAccounts@2022-09-01' existing = if (isTest) {
name: 'teststorageaccounttp'
}
resource saDev 'Microsoft.Storage/storageAccounts@2022-09-01' existing = if (isDev) {
name: 'devstorageaccounttp'
}
// supports multi-line and multiple conditions
output saName string = isProd ? saProd.name
: isTest ? saTest.name
: isDev ? saDev.name
: 'unknown'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment