Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.22k stars 747 forks source link

Deployment Pane: Load Azure Developer CLI environment #12460

Open jongio opened 10 months ago

jongio commented 10 months ago

With Azure Developer CLI

We have bicep parameter files that read env vars:

param environmentName = readFromEnvironmentVariable("AZURE_ENV_NAME")

Those values are store in current azd environment.

It would be nice if the deployment pane allowed the user to select the Azure Developer CLI environment they'd like to use.

Which would use azd to load the values needed for the parameters.

alex-frankel commented 10 months ago

@jongio - is there any documentation on azd environments and where they are stored? I don't quite understand how we could read anything other than the local environment variable with that specific name.

jongio commented 10 months ago

azd environments are stored in the projects .azure folder, but the interface with vscode is done via the cli.

You can get all environment variables with azd env get-values.

I can imagine a workflow like this.

  1. Add a button to deployment pane: "Load values from azd env"
  2. User selects env to use. The ext uses azd env list to show them.
  3. The ext loads the values with azd env get-values -e env-user-selected into the parameter list in the vscode ext.
  4. User then interacts with the ext as they do today.
alex-frankel commented 10 months ago

Still a bit lost, especially on the layering. Is bicep going to run azd up? I thought it was azd's job to deploy bicep (and whatever else is required), so it's confusing to me that bicep would be aware of azd at all.

The bicep extension in VS code is not explicitly loading up environment variables from a special location. It is querying the environment variable on the machine. Is there a gesture in azd to move environment variables from the .azure location to the environment variables on the machine?

Otherwise, I feel like there would need to be a special syntax for referencing variables from another location, i.e.:

param environmentName = readFromEnvironmentVariable("AZURE_ENV_NAME", 'azd') // adding a second argument for the environment variables location

Unless there is a syntax change, wouldn't that mean that the deployment would only work within the vscode deployment pane? what would happen if I deploy the bicep code via az CLI?

jongio commented 10 months ago

This is just to add a button to deployment pane, no bicep updates.

This feature would allow the user to populate the deployment pane parameter textboxes from an azd env.

Nothing else about deployment pane or bicep changes.

puicchan commented 9 months ago

We had an offline discussion. We agree to make this generic. The option proposed by Anthony is to detect env var dependencies and give the user ability to supply them. Mock up: image