Skip to content

fix(agents): validate discovered ACR connections#9225

Merged
trangevi merged 3 commits into
Azure:mainfrom
hund030:fix/validate-foundry-acr-connection
Jul 21, 2026
Merged

fix(agents): validate discovered ACR connections#9225
trangevi merged 3 commits into
Azure:mainfrom
hund030:fix/validate-foundry-acr-connection

Conversation

@hund030

@hund030 hund030 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #9224. Hosted container agent initialization no longer accepts stale ACR connections from an existing Foundry project and defers the failure until publish.

Changes

  • agent init: validate discovered container registry targets against ARM, skip missing registries, and preserve authorization or service errors.
  • ACR environment state: persist resource IDs for valid selections and clear stale connection values before manual or create-on-provision fallback.
  • Tests: cover valid, stale, mixed, manual fallback, and lookup-error scenarios.

Manual Validation

  • Built and installed the extension from this branch, then ran azd ai agent init -m against an existing Foundry project whose sole ACR connection referenced a deleted registry.
  • Confirmed init skipped the stale connection and cleared AZURE_CONTAINER_REGISTRY_ENDPOINT, AZURE_CONTAINER_REGISTRY_RESOURCE_ID, and AZURE_AI_PROJECT_ACR_CONNECTION_NAME, while setting AI_AGENT_PENDING_PROVISION=acr.
  • Set a valid replacement ACR and confirmed azd deploy resolved it and started an ACR build. The build later failed because that existing registry requires push credentials, after stale-connection handling had completed.

Copilot AI review requested due to automatic review settings July 21, 2026 06:44
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
21 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Validates discovered ACR connections during hosted agent initialization to avoid deferred publish failures.

Changes:

  • Verifies ACR targets and persists valid resource IDs.
  • Clears stale environment state during fallback.
  • Adds regression tests for validation and fallback paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
init_foundry_resources_helpers.go Adds ACR discovery validation and fallback state handling.
init_foundry_resources_helpers_test.go Tests valid, stale, mixed, fallback, and error scenarios.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_foundry_resources_helpers.go Outdated
@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jul 21, 2026
Copilot AI review requested due to automatic review settings July 21, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 21, 2026 08:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@trangevi
trangevi merged commit 4c84007 into Azure:main Jul 21, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd ai agent init selects a stale ACR connection without validating the registry

3 participants