Skip to content

feat(azure.ai.connections): migrate connection commands from azure.ai.agents#8357

Merged
trangevi merged 7 commits into
mainfrom
feat/migrate-connection-commands
May 27, 2026
Merged

feat(azure.ai.connections): migrate connection commands from azure.ai.agents#8357
trangevi merged 7 commits into
mainfrom
feat/migrate-connection-commands

Conversation

@hund030
Copy link
Copy Markdown
Collaborator

@hund030 hund030 commented May 25, 2026

Summary

Move the connection CRUD commands (list / show / create / update / delete) out of azure.ai.agents and into the new azure.ai.connections extension, so users invoke them as azd ai connection <verb>. Mirrors the azure.ai.projects and azure.ai.toolboxes migrations from earlier this cycle and removes the now-deprecated azd ai agent connection command tree from the agents extension.

Changes

  • azure.ai.connections — adds the connection CRUD commands, the data-plane client, the persistent -p / --project-endpoint flag, and internal/foundry/projectctx/ for endpoint resolution (same one-way-import contract as toolboxes, documented in a new AGENTS.md). Promotes internal/exterrors to the top level so the foundry package stays cmd-agnostic.
  • azure.ai.agents — drops the azd ai agent connection command tree (internal/connections/cmd, internal/connections/exterrors). Keeps internal/connections/pkg/connections because connection_credentials.go still uses it to resolve ${{connections.<name>.credentials.<key>}} placeholders at agent-run time.
  • Tests + lint — 18 new unit tests for projectctx (validator, resolver cascade via the stubbed ReadAzdHostedSourcesFunc seam, persisted-key constant). .golangci.yaml added matching sibling extensions. go test ./... and golangci-lint run ./... clean for both extensions.

Notes

  • Per-extension changelog/version bump and registry.json update are deliberately not in this PR — they ship as the standard PR1/PR2 release dance after this lands.
  • The extensions.ai-projects.context config-key bridge fix is intentionally not included here either; this extension stays aligned with azure.ai.toolboxes which has the same drift today. A separate change can bridge both in lockstep.

….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.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 25, 2026

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Review may take a bit longer — reach out to @rajeshkamal5050 or @kristenwomack if you'd like to discuss prioritization.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 connection CRUD commands in azure.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 connection command tree from azure.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.

@github-actions github-actions Bot added the ext-agents azure.ai.{agents,connections,inspector,projects,routines,skills,toolboxes} extensions label May 25, 2026
…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.
Comment thread cli/azd/extensions/azure.ai.connections/internal/connections/cmd/root.go Outdated
hund030 added 2 commits May 27, 2026 13:47
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>
@trangevi
Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

@copilot resolve the merge conflicts in this pull request

Resolved by merging origin/main and finalizing conflict resolution in commit 597a2bf.

@trangevi trangevi enabled auto-merge (squash) May 27, 2026 21:32
@trangevi
Copy link
Copy Markdown
Member

/check-enforcer override

@trangevi trangevi merged commit 8337596 into main May 27, 2026
43 of 45 checks passed
@hund030 hund030 deleted the feat/migrate-connection-commands branch June 3, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.{agents,connections,inspector,projects,routines,skills,toolboxes} extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate connections commands from agents extension to new connections extension

5 participants