Problem
Because the automated decompile approach fails, I’m currently attempting to manually convert an existing ARM template to bicep.
The variables in the present template are as follows:
"environmentSize": {
"dev": "small",
"msdn": "small",
"int": "small",
"act": "large",
"prod": "large"
},
"size": "[variables('environmentSize')[parameters('environment')]]",
What would the Bicep equivalent be?
I tried the following, but it’s clearly incorrect because a red squiggly appears beneath the $:
var environmentSize = {
dev:'small'
msdn:'small'
int:'small'
act:'large'
prod:'large'
}
var size = environmentSize.${environment}
Asked by Rob Bowman
Solution #1
It should work if you use brackets as a notation.
param environment string = 'dev'
var environmentSize = {
dev:'small'
msdn:'small'
int:'small'
act:'large'
prod:'large'
}
output size string = environmentSize[environment]
Answered by Thomas
Post is based on https://stackoverflow.com/questions/68863521/reference-object-variable-in-bicep-template