Skip to content

feat: adopt unified azure.yaml in azd ai agent init -m#8885

Merged
trangevi merged 6 commits into
mainfrom
hui/init-adopt-unified-azure-yaml
Jun 30, 2026
Merged

feat: adopt unified azure.yaml in azd ai agent init -m#8885
trangevi merged 6 commits into
mainfrom
hui/init-adopt-unified-azure-yaml

Conversation

@huimiu

@huimiu huimiu commented Jun 30, 2026

Copy link
Copy Markdown
Member

What

azd ai agent init -m <pointer> now accepts a sample's unified Foundry azure.yaml as an input. When the pointer resolves to a unified project manifest, init adopts that azure.yaml as the new project's manifest instead of generating one from an agent manifest.

Closes part of #8798 (fresh-project adoption). Existing-project merge is tracked separately in #8884.

Behavior

-m <azure.yaml>

When -m points to a unified azure.yaml / azure.yml:

  1. init treats it as a complete project manifest when its services: contain Foundry hosts such as azure.ai.project, azure.ai.agent, azure.ai.connection, or azure.ai.toolbox.
  2. A new azd project is initialized from the sample content.
  3. The sample's azure.yaml becomes the project-root azure.yaml.
  4. Files referenced by that manifest, including agent source folders and $ref files, keep their sample-relative layout.
  5. A normal azd environment is created under .azure/<env>.
  6. Bicep-less Foundry provisioning remains the default through infra.provider: microsoft.foundry.

Resulting shape:

<project-folder>/
  azure.yaml          # adopted from the sample
  .azure/<env>/       # azd environment
  <sample files...>   # source folders, $ref files, README, etc.

This path does not generate agent services from an agent manifest, does not bury the sample's azure.yaml under src/<agent>/, and does not duplicate Foundry resources that are already declared in the unified manifest.

-m <agent.manifest.yaml>

Existing behavior is preserved. The agent manifest remains a template input: init resolves manifest parameters and prompts, then generates or updates the project azure.yaml from that manifest.

Scope

This PR covers fresh-project adoption. If the target directory already has azure.yaml / azure.yml, adoption is refused with guidance instead of overwriting or merging. Merging a sample's services into an existing project is tracked in #8884.

Tests

Added coverage for unified-manifest detection, local/GitHub staging behavior, azure.yml normalization, target-directory conflict checks, and staging cleanup. Full agents-extension checks are passing.

Copilot AI review requested due to automatic review settings June 30, 2026 15:08
@github-actions github-actions Bot added the ext-agents azure.ai.agents extension label Jun 30, 2026

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

This PR updates the azd ai agent init -m <pointer> flow in the azure.ai.agents extension to detect when -m points at a sample’s unified Foundry azure.yaml and, in that case, adopt that manifest (and its sibling files) as the project’s root manifest via azd init -t, rather than generating a new project manifest from an agent manifest.

Changes:

  • Adds unified-azure.yaml detection (looksLikeFoundryAzureYaml) and a new adoption path (runInitFromAzureYaml) that stages local/remote sample directories and adopts them as the project template.
  • Refactors project scaffolding into shared helpers (deriveEnvName, scaffoldProject) used by both the legacy manifest flow and the new adoption flow.
  • Adds unit tests for adoption helpers and documents the new behavior in the extension changelog.

Reviewed changes

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

File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Routes -m pointers to adoption vs legacy manifest behavior, and refactors project scaffolding into shared helpers.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go Implements unified azure.yaml detection, local/remote staging, and adoption via azd init -t.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt_test.go Adds tests covering detection, naming/dir derivation, and local staging behavior.
cli/azd/extensions/azure.ai.agents/CHANGELOG.md Adds a feature entry describing the new adoption behavior and its limitations.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

4 files changed (+722 -68). Clean refactor of ensureProject into reusable scaffoldProject/deriveEnvName, plus a new adoption path for unified azure.yaml manifests.

The detection logic (looksLikeFoundryAzureYaml) is solid and the routing between adoption vs generation is unambiguous. Test coverage on the new helpers is thorough.

A few items worth considering inline.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Incremental review (1 new commit since my last pass: �2c38f4).

Prior findings are all addressed:

  • Conflict check now correctly uses projectManifestExists(targetDir) instead of CWD-relative ileExists
  • �zure.yml is properly normalized to �zure.yaml via �nsureStagedAzureYaml for both local and remote staging
  • Staged source manifest is removed to prevent duplicates
  • Private repo detection now works through the authenticated gh CLI fallback

One minor nit inline.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Incremental review (1 new commit since my last pass: 02c38f4).

Prior findings are all addressed:

  • Conflict check now correctly uses projectManifestExists(targetDir) instead of CWD-relative fileExists
  • azure.yml is properly normalized to azure.yaml via ensureStagedAzureYaml for both local and remote staging
  • Staged source manifest is removed to prevent duplicates
  • Private repo detection now works through the authenticated gh CLI fallback

One minor nit inline (on the prior review submission - formatting was fixed).

@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_adopt.go
@trangevi

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

The merge conflict has been resolved locally — CHANGELOG.md was the only file with a conflict (both the unified azure.yaml adoption entry from this branch and the code-deploy-default-change entry from main are kept). However, the push is being rejected by a branch protection rule on hui/init-adopt-unified-azure-yaml ("Cannot update this protected ref").

The resolution needed in CHANGELOG.md is straightforward — replace the conflict markers by keeping both bullet points:

- `azd ai agent init -m <pointer>` now adopts a sample's unified `azure.yaml`... (this branch)
- **Breaking (behavioral):** `azd ai agent init` now defaults to **code deploy**... (from main)

The branch can be updated by running from the feature branch:

git fetch origin main
git merge origin/main
# resolve CHANGELOG.md — keep both bullet points in Features Added
git add cli/azd/extensions/azure.ai.agents/CHANGELOG.md
git commit
git push

Copilot AI requested a review from trangevi June 30, 2026 18:39
@trangevi

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

The branch protection on hui/init-adopt-unified-azure-yaml is blocking all automated pushes, including from the Copilot agent. The conflict resolution is prepared locally but cannot be pushed.

The only conflict is in CHANGELOG.md — both bullet points need to be kept in Features Added. Please apply it manually:

git fetch origin main
git merge origin/main

Then edit CHANGELOG.md to replace the conflict markers with both entries:

### Features Added

- `azd ai agent init -m <pointer>` now adopts a sample's unified `azure.yaml`...
- **Breaking (behavioral):** `azd ai agent init` now defaults to **code deploy**...
git add cli/azd/extensions/azure.ai.agents/CHANGELOG.md
git commit
git push

@trangevi trangevi enabled auto-merge (squash) June 30, 2026 19:58
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.

[ext-agents]: azd ai agent init should adopt the sample's azure.yaml, not scaffold/clone from azd-ai-starter-basic (unified azure.yaml + bicep-less)

6 participants