Skip to content

feat: add Foundry project ownership core - #9559

Open
Hui Miao (huimiu) wants to merge 6 commits into
mainfrom
hui/foundry-projects-core
Open

feat: add Foundry project ownership core#9559
Hui Miao (huimiu) wants to merge 6 commits into
mainfrom
hui/foundry-projects-core

Conversation

@huimiu

@huimiu Hui Miao (huimiu) commented Aug 13, 2026

Copy link
Copy Markdown
Member

Closes #9564

Why this is needed

azure.ai.projects already owns provisioning for host: azure.ai.project, but project authoring and reconciliation were still split across extensions. That made standalone project setup harder and left project identity, endpoints, managed deployments, and environment state with inconsistent ownership.

What this PR does

This PR moves the core project authoring flow into azure.ai.projects:

  • Adds azd ai project init to create a new project, adopt an existing project by ARM resource ID, or configure an existing project endpoint.
  • Adds azd ai project deployment add to select and record managed model deployments in the project service.
  • Adds a versioned delegated request contract for agent-driven calls.
  • Resolves project identity and Azure context, updates project-owned environment values, and keeps legacy project service entries working.
  • Enforces project ID requirements for existing-project reconciliation and delegated location restrictions.
  • Supports optional Bicep or Terraform infrastructure ejection, with cleanup and configuration rollback when an update fails.
  • Documents the greenfield, existing-project, and endpoint-only flows and adds regression coverage.

Why this approach

The extension that owns host: azure.ai.project should also own its service configuration. Keeping project initialization and deployment authoring as separate commands lets a project exist without a model deployment, while the delegated contract lets higher-level flows orchestrate both operations when needed.

Scope

This PR implements the projects-side ownership core. The Agents handoff, recording proxy, and infrastructure layering work remain separate follow-ups.

Related to #9085 and based on the ownership design in #9441.

@azure-pipelines

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

@github-actions github-actions Bot added the ext-projects azure.ai.projects extension label Aug 13, 2026
@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 Rick Winter (@RickWinter) and Kristen Womack (@kristenwomack) to let us know.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
20 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

Adds Foundry project ownership and authoring to azure.ai.projects.

Changes:

  • Adds project initialization, adoption, and infrastructure ejection.
  • Adds managed model deployment authoring.
  • Adds delegated contracts, reconciliation, environment updates, and tests.

Reviewed changes

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

Show a summary per file
File Description
internal/exterrors/errors.go Adds compatibility errors.
internal/cmd/root.go Registers new commands.
internal/cmd/project_service_reconciler.go Reconciles project services.
internal/cmd/project_ownership_test.go Adds ownership-flow tests.
internal/cmd/project_init.go Implements project initialization and ejection.
internal/cmd/project_environment.go Manages project environment state.
internal/cmd/project_deployment.go Selects and reconciles deployments.
internal/cmd/project_deployment_add.go Implements deployment addition.
internal/cmd/delegated_contract.go Defines delegated request contracts.
go.mod Promotes RPC types to a direct dependency.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/azd/extensions/azure.ai.projects/internal/cmd/project_deployment_add.go Outdated
Comment thread cli/azd/extensions/azure.ai.projects/internal/cmd/project_init.go Outdated
Comment thread cli/azd/extensions/azure.ai.projects/internal/cmd/root.go
Comment thread cli/azd/extensions/azure.ai.projects/internal/cmd/project_init.go Outdated
Copilot AI review requested due to automatic review settings August 13, 2026 14:24
@github-actions github-actions Bot added area/extensions Extensions (general) ext-agents azure.ai.agents extension labels Aug 18, 2026

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.

I'm concerned about adding new commands before we have closure on the new proposed end to end path which John has been working on. Let's sync on that before moving forward with the new commands here

if len(body) == 1 {
return nil
}
if _, err := r.client.Project().SetServiceConfigSection(

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.

azd-code-reviewer: Can we make creation of the replacement service atomic, or remove the host-only service if this second write fails? During legacy migration, AddService can succeed and this call can fail, leaving an azure.ai.project service with none of the copied deployments/hooks/config. On retry, discovery prefers that incomplete project service over the legacy service, so the migration reports success without ever copying the legacy configuration, and the Foundry provider then ignores the still-complete legacy host.

return err
}
}
if err := reconcileProjectEnvironment(

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.

azd-code-reviewer: Please make the infrastructure and environment updates atomic or explicitly retryable. If an environment SetValue/UnsetValue fails here after root Terraform ejection succeeds, azure.yaml has already switched to terraform and infra/ exists. A retry cannot finish reconciliation: project init rejects the now-non-Foundry root provider (and --infra also encounters the existing directory). Rolling back ejection on this error, or recognizing the matching completed ejection on retry, would avoid stranding the project after a transient environment write failure.

azureContext.Scope.Location = values["AZURE_LOCATION"]
}
if azureContext.Scope.SubscriptionId == "" {
if deploymentContext, contextErr := client.Deployment().GetDeploymentContext(

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.

azd-code-reviewer: This fallback cannot actually recover a missing subscription: GetDeploymentContext reads the same selected environment's AZURE_SUBSCRIPTION_ID, so it remains empty. It also replaces already resolved AZURE_TENANT_ID and AZURE_AI_DEPLOYMENTS_LOCATION with the deployment context's values (whose location comes from AZURE_LOCATION), and its error is ignored. The command then reaches catalog/quota calls with an empty subscription and possibly the wrong location. Please resolve or prompt for the missing subscription (and fail deterministically in --no-prompt) while preserving the other fields rather than replacing the whole context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Extensions (general) ext-agents azure.ai.agents extension ext-projects azure.ai.projects extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harden the Foundry project ownership flow

3 participants