feat: add azd ai agent project commands for Foundry endpoint management#8162
Conversation
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
This PR extends the azure.ai.agents azd extension with a new project command group for managing a persisted Microsoft Foundry project endpoint, and upgrades endpoint resolution for agent commands to use a 5-level cascade (flag → azd env → global config → host env var → structured error). It also adds endpoint URL validation/normalization, introduces a new structured error code, and documents the new host environment variable.
Changes:
- Added
azd ai agent project {set|unset|show}commands to persist/clear/inspect the Foundry project endpoint in~/.azd/config.json. - Implemented a shared 5-level project endpoint resolver and updated agent endpoint resolution to use it.
- Added endpoint validation helpers, unit tests for validation + parts of the resolver, and documented
FOUNDRY_PROJECT_ENDPOINT.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/exterrors/codes.go | Adds missing_project_endpoint error code for structured dependency errors. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/root.go | Wires the new project command group into the extension command tree. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project.go | Defines the project parent command and registers set/unset/show subcommands. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_set.go | Implements project set to validate and persist an endpoint (with warnings). |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_unset.go | Implements project unset to clear persisted endpoint (idempotent). |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_show.go | Implements project show to resolve and print endpoint + source (table/json). |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_endpoint.go | Adds endpoint source enum, host suffix validation, normalization, and missing-endpoint error helper. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_context_store.go | Adds global config read/write helpers for persisted endpoint context. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/agent_endpoint.go | Adds guidance comment about keeping host-suffix validation logic in sync. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/agent_context.go | Implements the 5-level resolver and routes resolveAgentEndpoint through it. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_unset_test.go | Adds basic command-arg and output-flag configuration tests for unset. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_show_test.go | Adds basic command-arg/flag tests plus helper-function tests for show. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_set_test.go | Adds basic command-arg and output-flag configuration tests for set. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_resolver_test.go | Adds unit tests for resolver flag precedence + host env fallback + error cases. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/project_endpoint_test.go | Adds unit tests for endpoint validation/normalization and missing-endpoint error typing. |
| cli/azd/docs/environment-variables.md | Documents FOUNDRY_PROJECT_ENDPOINT as a host-level fallback source. |
- project_show.go: use errors.AsType[*azdext.LocalError] per AGENTS.md guidance - agent_context.go: extract azd-hosted source lookup (levels 2 + 3) into a stubbable seam (readAzdHostedSourcesFunc) for testability - project_resolver_test.go: add unit tests for AZURE_AI_PROJECT_ENDPOINT from azd env (success + invalid) and global config (success + invalid), plus a hosted-sources error propagation test; isolate non-azd tests from any developer-machine AZD_SERVER by clearing the env var and stubbing the seam Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jongio
left a comment
There was a problem hiding this comment.
Clean implementation of the project command group. The 5-level cascade is well-designed, validation is strict at every level (no silent fallthrough on bad values), and the stubbable seams (readAzdHostedSourcesFunc, lookupEnvFunc) make the resolver testable without a running daemon. Tests cover the priority ordering and error cases thoroughly.
|
Thanks for the thorough review! Addressed all the feedback in this update: From @jongio:
From @trangevi:
|
|
/check-enforcer override The build is showing complete, status is just not being reported |
JeffreyCA
left a comment
There was a problem hiding this comment.
Approving for cli/azd/docs/environment-variables.md change, looks good!
Summary
Adds
azd ai agent projectcommand group to theazure.ai.agentsextension, enabling users to persist and resolve a Microsoft Foundry project endpoint without requiring an azd environment or explicit flags on every command.Changes
projectcommand group (project set,project unset,project show): persists the Foundry project endpoint in~/.azd/config.jsonunderextensions.ai-agents.context.endpoint.agent_context.go: resolves from (1)--project-endpointflag, (2) active azd envAZURE_AI_PROJECT_ENDPOINT, (3) global config, (4) host env varFOUNDRY_PROJECT_ENDPOINT, then (5) structured error with actionable guidance.project_endpoint.go): validates and normalizes Foundryhttps://*.services.ai.azure.comURLs; surfaces a non-fatal warning when the path doesn't match/api/projects/<name>.project_context_store.go): read/write helpers for the global config store.FOUNDRY_PROJECT_ENDPOINTtoenvironment-variables.md.Related
Closes #8124
Design spec: #8152
Test