azure-cli
azure-cli copied to clipboard
Bicep "concat()" doesn't play nicely with "what-if"
Describe the bug
We use Bicep to deploy Azure Container Apps. We have a lot of apps, so we concatenate a base list of environment variables to each app, which then adds its own on top of that like this:
env: concat(myContainerApp.additionalEnvVars, [
{
name: 'MY_ENV_VAR'
value: 'myValue'
}
// snip...
]
When I run az deployment group what-if
to review the changes that will happen, even if nothing is actually changing at all, the entire environment variable section of the config is listed as a change every time.
The output of what-if
looks like this:
~ properties.template.containers: [
~ 0:
~ env: [
// ... all of my environment variables, as if I'm deleting them all (which I'm not)
// ...
] => "[concat(variables('myContainerApps')[copyIndex()].additionalEnvVars, createArray(createObject('name', 'MY_ENV_VAR', 'value', //...unreadable concatenated block of text that shows some kind of intermediate scripting language instead of just showing the resultant array
To Reproduce:
Run az deployment group what-if
with any bicep file that uses concatenation
Expected Behavior
I expect the "before" and "after" results from the what-if
command to show me the computed values, not some kind of intermediate scripting language. It's impossible to know if one of my container apps has a change in its environment variables, because all my apps show this mess in the what-if
output.
Environment Summary
Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.31, Ubuntu 20.04.3 LTS
Python 3.10.5
Installer: DEB
azure-cli 2.38.0 *
Extensions:
containerapp 0.3.7
storage-preview 0.8.3
Dependencies:
msal 1.18.0b1
azure-mgmt-resource 21.1.0b1
Additional Context
Hi @rickbatka,
2.38.0 is not the latest Azure CLI(2.47.0).
Please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.
Thank you for opening this issue, we will look into it.
I updated with az upgrade
and az bicep upgrade
. The problem still persists.
Thank you for your feedback. This has been routed to the support team for assistance.
Anybody able to look into this? As my cluster size has grown, I've found it increasingly hard to do my job without a proper "what-if" tool.
As it stands today, I'm using Bicep "the Bicep way", doing infrastructure-as-code, trying to use the Azure supported tools instead of something like Terraform, and I'm completely stuck. Every time I run "what-if", it tells me that all my resources are changing - even when I'm changing nothing. It's enough to render the tool useless. I'm surprised more people aren't complaining about this (are they?).
I can't get any insight into the changes that will be made when I run my script. I have resorted to locking my team out of Azure and making the rule that only I can do infrastructure releases, and I must do them the same way from the same machine every time. And if something does break, it will be very hard to figure out what changed to cause the breakage.
Any updates on this? Would really help my team immensely if we could use what-if and Bicep together
Does it help to use string interpolation instead, as suggested by Bicep doc and linter?
Doc:
- Concat: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-string#concat
- Which points to: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/data-types#strings
Linter rule:
Edit: Sorry, I hadn't read the replies in https://github.com/Azure/arm-template-whatif/issues/317 before posting this.