azure.yaml, what the Microsoft Foundry platform provides automatically, and how azd environment integration works. You also learn how to add custom variables and handle local development secrets.
Agent manifests (
agent.manifest.yaml) and standalone agent definitions (agent.yaml) are deprecated. As of the Foundry azd extensions (azure.ai.agents 1.0.0-beta.1), all hosted agent configuration lives in a single azure.yaml. See Author azure.yaml for hosted agents.Prerequisites
- An initialized hosted agent project with an
azure.yamlfile. To create or update a project, see Author azure.yaml for hosted agents. - The azd Foundry extensions installed. For installation steps, see Install the azd Foundry extensions.
- An authenticated Azure Developer CLI session. Run
azd auth loginif needed. - An active azd environment. Select or create one with
azd env selectorazd env new.
Define environment variables in azure.yaml
Define environment variables in theenv map of the azure.ai.agent service in your project azure.yaml, not in your Dockerfile. This approach keeps your container image portable and lets you change configuration without rebuilding.
${VAR_NAME} syntax to reference azd environment variables. The platform resolves these variables at deploy time from .azure/<env>/.env.
Why not the Dockerfile? Values baked into a Dockerfile are fixed at image build time and visible to anyone with access to the image. Using
azure.yaml lets you change values per environment and keeps secrets out of the image layer.Don’t declare
FOUNDRY_PROJECT_ENDPOINT in the azure.yaml env map. The platform injects it automatically into hosted containers, and azd ai agent run sets it for local development from the active azd env. Declaring it explicitly is redundant and risks shadowing the platform-managed value.Set azd environment variables
-
Add or change a variable in your current azd environment:
-
View all current values:
These values are stored in
.azure/<env-name>/.envand resolved into yourazure.yamlat deploy time.
Review platform environment variables
The Foundry platform automatically injects the following environment variables into every hosted agent container at startup. These variables are read-only. Your agent code should consume them but never override them.Foundry variables
Reserved prefix: The platform reserves all
AGENT_* and FOUNDRY_* environment variables for platform use and automatically injects them into the container.azd ai agent run, azd sets FOUNDRY_PROJECT_ENDPOINT automatically from your azd environment so your agent code works the same locally and when deployed.
Network variables
Observability variables
Session file variables
Add a new environment variable
-
Define the variable in the
envmap for theazure.ai.agentservice inazure.yaml. -
Set the value in your azd environment.
-
Redeploy the application.
azd ai agent run also resolves ${VAR} from the azd environment, so the same setup works locally.
Handle sensitive values
For secrets such as API keys and tokens, don’t bake values into your image or commit them toazure.yaml. Store secrets in a Foundry project connection, and reference connection values from your configuration when the platform supports that connection type.
Use secrets during local development
For local runs withazd ai agent run, set values as azd environment variables and reference them in azure.yaml. azd stores environment values in .azure/<env>/.env, which is gitignored by default, so they stay out of source control.
.env file, store them in a Foundry project connection and reference them with a ${{connections.<name>.credentials.<field>}} placeholder. The platform resolves the placeholder at runtime. See Run a hosted agent locally with the Azure Developer CLI for the local run workflow.
Related content
- Author azure.yaml for hosted agents to configure hosted agent services.
- Azure YAML reference for azd environments and
azd env set. - Deploy a hosted agent to redeploy after configuration changes.