The Azure Developer CLI (azd
) lets you manage multiple deployment environments for your projects, to keep configurations separate for development, testing, and production. This article explains essential concepts about how you can use environments to manage your development and deployment process.
An environment in the Azure Developer CLI (azd
) is a named set of configurations for a deployment of your app, such as dev, test, or prod. Different environments can be configured with different values. Environments serve several important purposes:
Each environment has its own Azure resource group and configuration settings. This environment isolation helps prevent changes in one environment from affecting others.
Environment structure and configurationAzure Developer CLI (azd
) environments live in a directory structure within your project:
âââ .azure [Created when you run azd init or azd up]
â âââ <environment-name-1> [Directory for environment-specific configurations]
â â âââ .env [Environment variables for this environment]
â â âââ config.json [Additional configuration parameters for this environment]
â âââ <environment-name-2> [Another environment]
â â âââ .env
â â âââ config.json
â âââ config.json [Global azd configuration]
The key components of this structure are:
.azure
directory: The root directory for all environment configurations. Excluded from source control by the .gitignore
file by default.dev
, test
, prod
..env
file: Contains environment-specific variables used by your application and during deployment.config.json
: Used to drive settings that influence azd
command behavior and features. This file isn't intended to be used directly by end users.Environment naming typically follows these patterns:
<project-name-[dev/int/prod]>
<personal-unique-alias-[dev/int/prod]>
These naming conventions aren't enforced by azd
and are configurable by the user.
Azure Developer CLI Environment variables provide a way to store configuration settings that influence and might vary between environments. When you run Azure Developer CLI commands, these variables are used to:
The .env
file contains these variables in a standard format:
AZURE_ENV_NAME=dev
AZURE_LOCATION=eastus
AZURE_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000
AZURE_RESOURCE_GROUP=rg-dev-12345
SERVICE_WEB_HOSTNAME=web-dev-12345.azurewebsites.net
SERVICE_API_HOSTNAME=api-dev-12345.azurewebsites.net
Common environment variables include:
Variable DescriptionAZURE_ENV_NAME
Name of the current environment AZURE_LOCATION
Azure region where resources are deployed AZURE_SUBSCRIPTION_ID
ID of the Azure subscription used for this environment AZURE_RESOURCE_GROUP
Name of the resource group for this environment
Tip
For other common environment variables and service-specific examples, visit the Environment variables documentation.
When working with environment variables:
.env
files to source control. If environment configuration needs to be persisted or shared, users should use Remote environments.azd env set
command to update variables safely.Warning
Never store secrets in an Azure Developer CLI .env
file. These files can easily be shared or copied into unauthorized locations, or checked into source control. Use services such as Azure Key Vault or Azure Role Based Access Control (RBAC) for protected or secretless solutions.
Many programming frameworks and tools such as Node.js, Django, or React use .env
files for configuration. While Azure Developer CLI (azd
) also uses .env
files, there are important differences:
.env
Framework .env
Files Location Stored in .azure/<environment-name>/.env
Typically stored in project root directory Environment Support Support for multiple user-defined environments (dev, test, prod) Often require manual file switching or naming conventions (.env.development
, .env.production
) Loading Mechanism Automatically loaded by azd
commands Usually require explicit loading in application code or build scripts Integration Deeply integrated with Azure services and resource provisioning General purpose configuration, not Azure-specific Variable Management Managed via azd env
commands Typically edited manually or via custom scripts
While both serve similar purposes, Azure Developer CLI's .env
approach adds structure and tooling designed for managing multiple deployment environments and Azure resources.
Note
If your project already uses framework-specific .env
files, you can keep both configuration systems without conflicts. azd
environment variables override system environment variables of the same name for some operations.
Manage environment variables in Azure Developer CLI
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4