Azure / Azure/azure-cli

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

Open
#26,223 7 comments 1 reaction 1 assignee Claimed by @zhoxing-ms View on GitHub
act-identity-squad ARM Auto-Assign Auto-Resolve customer-reported question Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.