An azd environment variable is stored by the azd CLI for each environment. It is passed to the "azd up" command and can configure both provisioning options and application settings.
When adding new azd environment variables, update these files:
-
infra/main.parameters.json: Add the new parameter mapping from azd env variable to Bicep parameter
- Use format
${ENV_VAR_NAME}for required values - Use format
${ENV_VAR_NAME=default}for optional values with defaults - Example:
"mcpAuthProvider": { "value": "${MCP_AUTH_PROVIDER=none}" }
- Use format
-
infra/main.bicep: Add the Bicep parameter declaration at the top with
@description- Use
@secure()decorator for sensitive values like passwords/secrets - Example:
@description('Flag to enable feature X') param useFeatureX bool = false
- Use
-
infra/server.bicep (or other module): If the variable needs to be passed to a container app:
- Add a parameter to receive the value from main.bicep
- Add the environment variable to the appropriate
envarray (e.g.,baseEnv, or a conditional array) - For secrets, add to a secrets array and reference via
secretRef
-
infra/main.bicep: Pass the parameter value to the module
- Example:
featureXEnabled: useFeatureX ? someValue : ''
- Example:
-
infra/write_env.sh and infra/write_env.ps1: If the variable should be written to
.envfor local development:- Add a line to echo/write the value from
azd env get-value - For conditional values, wrap in an if block to only write when populated
- Add a line to echo/write the value from
-
infra/main.bicep outputs: If the value needs to be stored back in azd env after provisioning:
- Add an output (note:
@secure()parameters cannot be outputs)
- Add an output (note:
When updating or adding Python dependencies:
- Edit
pyproject.tomlwith the new or updated version constraints. - Run
uv lockto re-resolve dependencies (useuv lock -P <package>to upgrade only a specific package). - Run
uv syncto install the updated lockfile into the virtual environment.