Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
azd ai commands run in two contexts: inside an azd project (the typical team workflow) and standalone (ad hoc work, one-off scripts, or invocations from automation that has no azure.yaml to anchor on). Both modes target the same Microsoft Foundry resources. They differ only in how the CLI determines which Foundry project to talk to. In this article, you learn the resolution order and how to set the standalone context.
Prerequisites
- The Azure Developer CLI Foundry extensions installed.
- An authenticated Azure session (
azd auth login). - An existing Foundry project endpoint for standalone use.
When to use each context
The resource commands (
azd ai connection, azd ai toolbox, azd ai skill, and azd ai routine) operate on a single Foundry project, so they need a project endpoint resolved from one of these contexts before they can run.
The azd ai agent commands (such as run, invoke, and optimize) aren’t standalone. They require an azd project for azure.yaml and environment resolution. Use --agent-endpoint on azd ai agent invoke to call a deployed agent without an azd project on disk.
How endpoint resolution works
For every command that targets a Foundry project, the CLI resolves the endpoint in this order. The first source that returns a value wins, and later sources aren’t consulted:- The
-por--project-endpointflag on the command. Always wins, regardless of context. - The active
azdenvironment, if you’re inside anazdproject directory. - Global config, under
extensions.ai-agents.context.endpointin~/.azd/config.json. This is whatazd ai project setwrites. - The
FOUNDRY_PROJECT_ENDPOINTenvironment variable in the current shell. - Error. The CLI exits with a structured suggestion to run
azd ai project setor pass--project-endpoint.
Set the standalone context
Theazd ai project set command writes the active Foundry project endpoint to your global azd config, so subsequent commands run from anywhere can omit --project-endpoint. The command takes the endpoint as a positional argument:
--no-prompt in scripts and CI so a missing or unresolved value fails fast instead of blocking:
Only the endpoint is canonical. Resource commands re-derive the subscription, resource group, account, and project from the endpoint at call time.
Clear the standalone context
context block from ~/.azd/config.json. It doesn’t touch any azd environment values.
Inspect the active context
Theazd ai project show command walks the full resolution chain and reports which source provided the active endpoint. Use it to confirm what your next command targets before you run it:
azd project, the Source line reads azd env <env-name> instead, and the displayed values come from the environment’s .env file rather than from global config.
Storage location
The standalone context lives under theextensions.ai-agents namespace in ~/.azd/config.json:
endpoint is canonical. The other fields exist to make azd ai project show readable. The CLI never reads them when resolving a target. You can edit the file by hand, but azd ai project set and azd ai project unset are the supported way to manage it.
Precedence inside an azd project
Inside anazd project, the active environment’s project endpoint always wins over the global context. Running azd ai project set from within a project still updates global config, but the CLI prints a one-line warning that the environment continues to take precedence for commands run from that directory.
This behavior is intentional. Project-level environment values are part of the team’s workflow, while the global context is a per-machine preference. To override the environment for a single command from inside a project, pass --project-endpoint, or set FOUNDRY_PROJECT_ENDPOINT in the shell, instead of relying on global config.