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

[Issue] outputs from main.bicep added to .azure/.env occasionally include a casing error

Open greenie-msft opened this issue 2 years ago • 2 comments

  • [x] Make sure you've installed the latest version using instructions in the wiki

Output from azd version Run azd version and copy and paste the output here: azd version 0.1.0-beta.4 (commit fd96b3e9b283598bc4dc736e893f1b47080fbf7d)

Output from az version Run az version and copy and paste the output here (minimum required version is 2.38.0): azd version 0.1.0-beta.4 (commit fd96b3e9b283598bc4dc736e893f1b47080fbf7d)

Describe the bug Description of issue you're seeing... Occasionally (not always) outputs from main.bicep are exported to .env with casing errors:

output POSTGRES_USER string = binding.outputs.POSTGRES_USER

results in:
pOSTGRES_USER=XXXXXXX

To Reproduce Output variables from main.bicep

Expected behavior Environment variables should respect casing when added to .env file.

greenie-msft avatar Aug 22 '22 23:08 greenie-msft

Related? https://github.com/Azure/azure-dev/issues/289

jongio avatar Aug 23 '22 16:08 jongio

This is somewhat surprising as we do explicit work to try to prevent this from happening. ARM does not retain the case of output property names (this is a known issue) in the deployment object and so we use ARM Template to discover the canonical case of the outputs and then use that when updating the environment.

That logic lives here: https://github.com/Azure/azure-dev/blob/eff5410e6e0d1cac190823ee0ab5dfa06f43c1c4/cli/azd/pkg/iac/bicep/compile.go#L41-L59

It's possible that we aren't running it in some cases?

@greenie-msft You mentioned this is intermittent - I'm wondering what azd command you're running when you trigger this? The intermittentness concerns me.

Also - when this happens is the original (correctly cased) POSTGRESS_USER removed from the environment or is it still around as well as the bad cased version?

ellismg avatar Aug 23 '22 17:08 ellismg

@ellismg, I just reviewed my shell history and the command I used (every time) was : azd env set POSTGRES_USER XXXX

When behavior occurs, it does not remove the correct environment variable from previous attempts. I had the below in my .env file:

POSTGRES_USER=XXXX pOSTGRES_USER=XXXX

greenie-msft avatar Aug 29 '22 16:08 greenie-msft

@greenie-msft since you said occasionally. Did you run into this recently?

rajeshkamal5050 avatar Oct 06 '22 05:10 rajeshkamal5050

I'm consistently running into this on a MacBook. Will investigate further, but at a glance:

  • The casing in .env file is correct
  • When running bicep build of the .bicep file, the outputs have correct casing
  • But in the deployment, I can see the casing is messed up: image

Suspicious that ARM may be involved here.

weikanglim avatar Apr 27 '23 23:04 weikanglim