azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Bicep "concat()" doesn't play nicely with "what-if"

Open rickbatka opened this issue 1 year ago • 7 comments

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

rickbatka avatar Apr 21 '23 16:04 rickbatka

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.

yonzhan avatar Apr 21 '23 16:04 yonzhan

I updated with az upgrade and az bicep upgrade. The problem still persists.

rickbatka avatar Apr 21 '23 19:04 rickbatka

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Apr 21 '23 22:04 ghost

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.

rickbatka avatar May 22 '23 23:05 rickbatka

Any updates on this? Would really help my team immensely if we could use what-if and Bicep together

rickbatka avatar Oct 18 '23 00:10 rickbatka