feat(azure.ai.connections): migrate connection commands from azure.ai.agents#8357
Conversation
….agents
Move the connection CRUD commands (list / show / create / update / delete)
from azure.ai.agents into the new azure.ai.connections extension so users
invoke them as `azd ai connection <verb>` instead of
`azd ai agent connection <verb>`.
Key adjustments vs source:
- Module path `azure.ai.connections`.
- Project endpoint resolution moved into `internal/foundry/projectctx`,
mirroring the `azure.ai.toolboxes` package layout (same one-way import
contract documented in AGENTS.md). The cascade and `Validate` rules
are inherited unchanged.
- `internal/exterrors` promoted to the extension top level so
`internal/foundry/` does not depend on connection-cmd-specific code.
- Update examples and persistent `-p / --project-endpoint` flag rewired
to the new extension root.
Agents extension is cleaned up in the same change:
- Drops the `azd ai agent connection` command tree
(`internal/connections/cmd` and `internal/connections/exterrors`).
- Retains `internal/connections/pkg/connections` because
`connection_credentials.go` still needs the data-plane client to
resolve `${{connections.<name>.credentials.<key>}}` placeholders at
agent-run time.
Tests:
- All migrated tests pass under the new module path.
- 18 new unit tests added for the `projectctx` package (validator,
resolver cascade with stubbed hosted-sources seam, persisted
config-key constant).
- `.golangci.yaml` added to match sibling extensions; lint clean.
…s/connectioncmd/tavily/tvly
📋 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 migrates the Foundry connection CRUD command surface from azure.ai.agents into the new azure.ai.connections extension so users run azd ai connection <verb>, while introducing a shared projectctx package for consistent project-endpoint resolution/validation within the new extension.
Changes:
- Added
azd ai connectionCRUD commands inazure.ai.connections, including data-plane access and raw ARM fallback paths. - Introduced
internal/foundry/projectctx(resolver + validator) with unit tests to enforce the 5-level endpoint cascade behavior. - Removed the deprecated
azd ai agent connectioncommand tree fromazure.ai.agents.
Reviewed changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/validator.go | Adds Foundry project endpoint URL validation + normalization and “no endpoint” structured error. |
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/validator_test.go | Unit tests for endpoint validation/normalization and error codes. |
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/types.go | Defines endpoint source/types used by the resolver cascade. |
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/store.go | Reads the persisted project context from global config (agents-owned key). |
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/store_test.go | Pins the cross-extension global-config key to prevent silent breaking changes. |
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/resolver.go | Implements the 5-level endpoint resolution cascade, with daemon-unavailable fallback logic. |
| cli/azd/extensions/azure.ai.connections/internal/foundry/projectctx/resolver_test.go | Verifies cascade ordering, normalization, and hard-error behavior on invalid values. |
| cli/azd/extensions/azure.ai.connections/internal/exterrors/errors.go | Adds structured error helpers and Azure SDK → service error conversion. |
| cli/azd/extensions/azure.ai.connections/internal/exterrors/codes.go | Adds/extends stable error codes, including invalid parameter for endpoint validation. |
| cli/azd/extensions/azure.ai.connections/internal/connections/pkg/connections/models.go | Defines connection models and credential parsing for the data-plane API. |
| cli/azd/extensions/azure.ai.connections/internal/connections/pkg/connections/models_test.go | Unit tests for credential parsing behavior. |
| cli/azd/extensions/azure.ai.connections/internal/connections/pkg/connections/data_client.go | Adds a data-plane client for listing connections and fetching credentials. |
| cli/azd/extensions/azure.ai.connections/internal/connections/cmd/root.go | Registers the connection CRUD subcommands under the parent command. |
| cli/azd/extensions/azure.ai.connections/internal/connections/cmd/raw_connection.go | Adds raw ARM PUT path for auth types not covered by the ARM Go SDK. |
| cli/azd/extensions/azure.ai.connections/internal/connections/cmd/endpoint.go | Removes duplicated endpoint resolution and relies on projectctx for validation/cascade. |
| cli/azd/extensions/azure.ai.connections/internal/connections/cmd/context.go | Switches connection context construction to use projectctx.Resolve. |
| cli/azd/extensions/azure.ai.connections/internal/connections/cmd/connection.go | Updates help/examples/import paths for the new azd ai connection command path. |
| cli/azd/extensions/azure.ai.connections/internal/connections/cmd/connection_test.go | Updates imports and adds tests for new/raw connection helpers. |
| cli/azd/extensions/azure.ai.connections/internal/cmd/root.go | Registers persistent -p/--project-endpoint flag and wires connection subcommands at extension root. |
| cli/azd/extensions/azure.ai.connections/go.mod | Updates module dependencies (adds grpc/testify, ARM cognitive services SDK). |
| cli/azd/extensions/azure.ai.connections/go.sum | Updates dependency checksums for the new/updated dependencies. |
| cli/azd/extensions/azure.ai.connections/AGENTS.md | Documents extension-specific conventions and package boundary rules. |
| cli/azd/extensions/azure.ai.connections/.golangci.yaml | Adds extension-local lint configuration. |
| cli/azd/extensions/azure.ai.agents/internal/connections/cmd/root.go | Removes the agents extension’s connection command subtree. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/root.go | Stops registering the removed connection command subtree under agents root. |
…jected version The data-plane client hard-coded its user-agent as `azd-ext-azure-ai-connection/0.1.0` (singular, frozen literal). Every release would have shipped that same string regardless of the extension version, defeating the point of having a user-agent in the first place. Mirror the azure.ai.agents wiring so the user-agent comes from a `-ldflags`-injected constant: - Add `internal/version` package (Version / Commit / BuildDate), matching `azure.ai.agents/internal/version`. - Point `build.sh` and `build.ps1` at the new package (was `internal/cmd`, which only `version.go` read). - Have `data_client.go` build the user-agent from `version.Version` and fix the name to plural `azd-ext-azure-ai-connections`. Pipeline label likewise pluralized for consistency. - Drop the redundant `Version/Commit/BuildDate` vars from `internal/cmd/version.go`; the `version` command now reads from the new package too, keeping a single source of truth. Resolves Copilot review feedback on PR #8357.
Address PR #8357 review feedback from trangevi: - Move internal/connections/cmd/ -> internal/cmd/ so commands live at the same depth as every other extension. Connection-context glue renamed connection_context.go to avoid colliding with the existing generic context.go verb. The RegisterCommands helper is inlined into internal/cmd/root.go (5 AddCommand calls; no helper package needed now that everything is in the same package). - Move internal/connections/pkg/connections/ -> internal/pkg/connections/ to match the convention used by other extensions. Also ports the connection-side changes from PR #8358 (OAuth2 fields and connector-name support) into the migrated copy. The plain `git merge origin/main` dropped them because rename-detection didn't follow our cross-directory migration; replayed by taking main's connection.go / connection_test.go / raw_connection.go from the agents copy and rewriting imports + example strings for the connections extension. Updates: - internal/cmd/root.go: drop the connectioncmd helper-package import; inline the 5 CRUD AddCommand calls. - internal/cmd/connection.go: imports azure.ai.connections/internal/exterrors (was the now-removed nested exterrors path); example strings use `azd ai connection` (was `azd ai agent connection`). - AGENTS.md: package-layout description and one-way import contract updated to reference internal/cmd/ + internal/pkg/ (was internal/connections/cmd/ + internal/connections/pkg/). - cspell.yaml: drop unused `connectioncmd` (the helper-package alias no longer exists). Verified by running the local e2e smoke test (Test_CLI_Connection_Smoke) end-to-end against a live Foundry project: build, pack, publish, install, create, list, show, show --show-credentials, update, post-update show, delete, post-delete show (expected 404) all pass.
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
Resolved by merging |
|
/check-enforcer override |
Summary
Move the connection CRUD commands (
list/show/create/update/delete) out ofazure.ai.agentsand into the newazure.ai.connectionsextension, so users invoke them asazd ai connection <verb>. Mirrors theazure.ai.projectsandazure.ai.toolboxesmigrations from earlier this cycle and removes the now-deprecatedazd ai agent connectioncommand tree from the agents extension.Changes
azure.ai.connections— adds the connection CRUD commands, the data-plane client, the persistent-p / --project-endpointflag, andinternal/foundry/projectctx/for endpoint resolution (same one-way-import contract as toolboxes, documented in a newAGENTS.md). Promotesinternal/exterrorsto the top level so the foundry package stays cmd-agnostic.azure.ai.agents— drops theazd ai agent connectioncommand tree (internal/connections/cmd,internal/connections/exterrors). Keepsinternal/connections/pkg/connectionsbecauseconnection_credentials.gostill uses it to resolve${{connections.<name>.credentials.<key>}}placeholders at agent-run time.projectctx(validator, resolver cascade via the stubbedReadAzdHostedSourcesFuncseam, persisted-key constant)..golangci.yamladded matching sibling extensions.go test ./...andgolangci-lint run ./...clean for both extensions.Notes
registry.jsonupdate are deliberately not in this PR — they ship as the standard PR1/PR2 release dance after this lands.extensions.ai-projects.contextconfig-key bridge fix is intentionally not included here either; this extension stays aligned withazure.ai.toolboxeswhich has the same drift today. A separate change can bridge both in lockstep.