Subchapter 28.7
references/recipes/azd/environment.mdMarkdown2 KBView on GitHub
⛔ MANDATORY: You MUST set up an AZD environment before running any deployment commands.
azd env listIf an environment is already selected (marked with *), check its current values:
azd env get-valuesIf AZURE_ENV_NAME, AZURE_SUBSCRIPTION_ID, and AZURE_LOCATION are already set, confirm with user:
Question: "An AZD environment is already configured. Would you like to use it?"
Environment: {env-name}
Subscription: {subscription-id}
Location: {location}
Choices: [
"Yes, use this environment (Recommended)",
"No, create a new environment"
]If user confirms → skip to Verify Configuration. Otherwise → continue to Step 2.
If NO environment exists or none is selected:
⛔ DO NOT use generic names like “dev”, “prod”, or “test”
These cause naming conflicts in Azure resource groups and resources. Always generate a unique name.
Use this pattern:
{project-name}-{random-4-chars}Examples:
dadjokes-x7k2todoapp-m3p9myapi-q5w8You MUST use ask_user to confirm the environment name:
I need to create an AZD environment for this deployment.
Suggested name: {project-name}-{random-4-chars}
Would you like to use this name or enter a custom one?After user confirms:
azd env new <environment-name> --no-promptSet subscription and location:
azd env set AZURE_SUBSCRIPTION_ID <subscription-id>
azd env set AZURE_LOCATION <location>azd env get-valuesConfirm these values are set:
AZURE_ENV_NAMEAZURE_SUBSCRIPTION_IDAZURE_LOCATIONAfter environment is configured, proceed with azd up --no-prompt.