Skip to content

[docs] Document cross-compute-environment hosted agent referencing for Azure AI Foundry - #1143

Closed
aspire-repo-bot[bot] wants to merge 3 commits into
release/13.5from
docs/foundry-cross-compute-environment-17756-30a5553400a1152f
Closed

aspire-repo-bot[bot] wants to merge 3 commits into
release/13.5from
docs/foundry-cross-compute-environment-17756-30a5553400a1152f

Conversation

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Documents changes from microsoft/aspire#17756.

Author: @davidfowl

Targeting release/13.4 based on the source PR milestone 13.4.

Why this PR is needed

microsoft/aspire#17756 shipped two significant user-facing improvements for Foundry hosted agents:

  1. Cross-compute-environment endpoint resolution — aspire deploy previously threw a "context not found" error when a resource referenced an endpoint whose owning resource was deployed to a different compute environment (e.g., a web app on AKS referencing a hosted agent in a Foundry project environment). This is now fixed for Azure Container Apps, Azure App Service, and Kubernetes publishers.

  2. RBAC auto-wiring — referencing a hosted agent from a different compute environment now automatically provisions the consumer's managed identity and grants the Azure AI User role on the owning Foundry account. Previously developers had to run two manual az role assignment create steps after every deploy.

Both changes are driven by a new experimental public type ReferenceRoleAssignmentAnnotation ([Experimental("ASPIREAZURE003")]).

Changes made

src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx

Added a new section "Reference a hosted agent across compute environments" (placed before the existing "Invoke agents from the Aspire dashboard" section) that:

  • Shows the C# and TypeScript AppHost patterns for cross-compute-environment hosted agent referencing.
  • Explains the two automatic behaviors: endpoint resolution and RBAC auto-wiring.
  • Includes an Aside noting the ASPIREAZURE003 experimental diagnostic with a link to the diagnostic reference.

src/frontend/src/content/docs/diagnostics/aspireazure003.mdx

Updated ASPIREAZURE003 reference page to:

  • Expand the page title and description from "Azure Virtual Networks" to "Azure experimental types and members".
  • Document both API families that now emit this diagnostic: Azure Virtual Networks and ReferenceRoleAssignmentAnnotation.
  • Add a code example for the hosted-agent cross-environment scenario with a cross-link to the integration doc.

Files modified

  • src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx — updated (new section added)
  • src/frontend/src/content/docs/diagnostics/aspireazure003.mdx — updated

Generated by PR Documentation Check for issue #17756 · ● 19.9M · ◷

… ReferenceRoleAssignmentAnnotation (ASPIREAZURE003)

- Add new section to azure-ai-foundry-host.mdx explaining how to reference
  a hosted agent from a different compute environment (e.g., AKS → Foundry
  project), covering both cross-environment endpoint resolution and auto-wired
  Azure AI User RBAC grant.

- Update aspireazure003.mdx to cover ReferenceRoleAssignmentAnnotation in
  addition to Azure Virtual Networks, since both use ASPIREAZURE003.

Documents changes from microsoft/aspire#17756.

Co-authored-by: Copilot <[email protected]>

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

Updates Aspire docs to explain cross-compute-environment referencing for Azure AI Foundry hosted agents, including the new automatic endpoint resolution and RBAC wiring behavior tied to ASPIREAZURE003.

Changes:

  • Added a new section to the Azure AI Foundry integration doc covering cross-environment hosted-agent references (C# + TypeScript).
  • Expanded ASPIREAZURE003 diagnostic documentation to cover additional experimental Azure hosting APIs and scenarios.

Reviewed changes

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

File Description
src/frontend/src/content/docs/integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host.mdx Adds cross-compute-environment hosted agent reference guidance and explains endpoint + RBAC behaviors.
src/frontend/src/content/docs/diagnostics/aspireazure003.mdx Broadens the diagnostic page from VNet-only to “Azure experimental types and members,” adding a hosted-agent example and cross-links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +605 to +610
const agent = await builder
.addProject('agent', '../Agent/Agent.csproj')
.withHttpEndpoint()
.withExternalHttpEndpoints();
await agent.asHostedAgent(project);

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.

Thanks for checking. I'm leaving this as written because the release/13.4 source exports the TypeScript-facing hosted-agent API as asHostedAgent. At microsoft/aspire@becb48e, src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs:48-50 says the polyglot-facing name is set back to asHostedAgent, and src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs:64-68 has [AspireExport("asHostedAgentExecutable", MethodName = "asHostedAgent")] taking the Foundry project. The TypeScript validation AppHost also calls await hostedAgent.asHostedAgent(project, ...) at tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.mts:118.

I did not apply the suggested withComputeEnvironment({ project }) change because the generated withComputeEnvironment(...) API takes a ComputeEnvironmentResource, as shown in tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts:32838, not the { project } object shape.

- Clarify ASPIREAZURE003 pragma context (PRRT_kwDOQK_VN86F_SIK)
- Mention TypeScript RBAC override API (PRRT_kwDOQK_VN86F_SIF)

Verified against microsoft/aspire@becb48e on branch release/13.4.
Edited per the doc-writer skill.

Co-authored-by: Copilot <[email protected]>

@IEvangelist David Pine (IEvangelist) 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.

Automated docs-accuracy review

Source of truth: microsoft/aspire branch release/13.4 at commit becb48e2d61099e35ae336d527d3875e928d6594.

Phase A — Claim verification

Verdict Count
verified 12
verified-with-nuance 1
contradicted 4
unverifiable 0
Total 17

Four claims contradicted by the source code on release/13.4 are flagged inline. All hinge on two issues: (1) the public hosted-agent API on release/13.4 is AsHostedAgent, not PublishAsHostedAgent; (2) cross-compute-environment endpoint resolution and ReferenceRoleAssignmentAnnotation are decoupled features in source — endpoint resolution does not require the annotation.

Phase B — Doc-tester run

Pages exercised (PR head ca73b4c3 overlaid onto local docs site at http://localhost:57129):

  • /diagnostics/aspireazure003/ (new ## Cross-compute-environment hosted agent reference example)
  • /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/ (new ## Reference a hosted agent across compute environments section)

Critical issues: 0 · Warnings: 4 · Knowledge gaps: 2 · Passed checks: 6

Detailed doc-tester report and the full per-claim catalog are in the collapsible sections below. Verdict: Request changes (Phase A has contradicted claims).

Phase A — All claims and verdicts (17)

Evidence paths refer to microsoft/aspire@becb48e2d61099e35ae336d527d3875e928d6594.

Verified (12):

# Location Claim Evidence
C1 aspireazure003.mdx:21,25 ReferenceRoleAssignmentAnnotation is in the Aspire.Hosting.Azure namespace. src/Aspire.Hosting.Azure/ReferenceRoleAssignmentAnnotation.cs:32
C2 aspireazure003.mdx:25 Used internally to auto-wire the Azure AI User role when a resource references a Foundry hosted agent. src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs:434-451
C5 foundry sample C# APIs AddAzureKubernetesEnvironment, AddFoundry, AddProject exist. src/Aspire.Hosting.Kubernetes/*, src/Aspire.Hosting.Foundry/*
C6 foundry sample WithComputeEnvironment(...) chains onto a project resource. src/Aspire.Hosting/ResourceBuilderExtensions.cs:4670
C8 aspireazure003 prose [Experimental("ASPIREAZURE003")] decorates ReferenceRoleAssignmentAnnotation. src/Aspire.Hosting.Azure/ReferenceRoleAssignmentAnnotation.cs:31
C9 foundry L1144 Endpoint-resolution fix affects ACA, App Service, and Kubernetes publishers. BaseContainerAppContext.cs:228,286, AzureAppServiceWebsiteContext.cs:173,218, KubernetesResource.cs:492,529
C10 foundry L1147-1149 Consumer's managed identity is auto-stamped with Azure AI User on the Foundry account. HostedAgentBuilderExtension.cs:446
C12 foundry L609 (TS) TypeScript surface method is agent.asHostedAgent(project). [AspireExport("asHostedAgentExecutable", MethodName = "asHostedAgent")] at HostedAgentBuilderExtension.cs:64; polyglot test tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.mts:118
C13 foundry TS sample TS API names (addAzureKubernetesEnvironment, addFoundry, addProject, withHttpEndpoint, withExternalHttpEndpoints, withComputeEnvironment, withReference) exist. *.ats.txt surface files
C14 foundry L1245 WithRoleAssignments(...) (C#) and withFoundryRoleAssignments(...) (TS) suppress/override the implied RBAC stamp. src/Aspire.Hosting.Foundry/api/*.ats.txt; existing role-assignments docs on the same page (L1527)
C15 foundry L1142-1145 Before the fix, aspire deploy threw "context not found" for cross-environment endpoint refs. matches commit message of microsoft/aspire#17756
C16 foundry L1245 Role stamp is "only emitted when the reference is present" (least-privilege). HostedAgentBuilderExtension.cs:434-451 — annotation added inside the WithReference callback path

Verified-with-nuance (1):

# Location Nuance
C17 foundry L564 (#pragma warning disable ASPIREAZURE003 in C# sample, plus Aside's "Suppress this diagnostic to use the feature") The supported public API for end users is AsHostedAgent + WithReference + WithComputeEnvironment. None of these are experimental in source. ReferenceRoleAssignmentAnnotation is created and read internally with #pragma warning disable ASPIREAZURE003 already applied at file scope in src/Aspire.Hosting.Azure/AzureResourcePreparer.cs:4 and around HostedAgentBuilderExtension.cs:449-451. End users using the documented sample as written should not need the pragma. See the inline comment for the suggested rewording.

Contradicted (4): see inline comments.

Phase B — Doc-tester report

Tester scope: only the pages and sections affected by this PR's diff. PR head ca73b4c3 was overlaid onto the local docs site (http://localhost:57129) and rendered with the worktree's Astro dev server. Findings are based purely on what the rendered docs convey to a reader who has no access to source code.

Summary

Category Passed Warnings Critical
Content accuracy (blind reading) 4 2 0
Code examples (copy-pasteable) 1 1 0
Cross-links & anchors 2 0 0
Knowledge gaps n/a 2 n/a

Critical issues

None observable from the rendered docs alone. The factual contradictions caught by Phase A are not visible to a blind reader.

Warnings

W1 — C#/TypeScript asymmetry on #pragma warning disable ASPIREAZURE003. The C# sample at /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/#reference-a-hosted-agent-across-compute-environments opens with #pragma warning disable ASPIREAZURE003 // ReferenceRoleAssignmentAnnotation is experimental and required for cross-environment RBAC wiring. The TypeScript sample contains no equivalent suppression and no explanatory comment. A blind reader is left to guess whether the diagnostic is .NET-only, whether TypeScript users need an analogous step, or whether the asymmetry is a documentation oversight. Either both samples should suppress (and explain the suppression) or a one-line note should clarify that ASPIREAZURE003 only fires for C# AppHosts.

W2 — Aside conflates two distinct behaviors. The Aside at the top of the new section says: "Cross-compute-environment endpoint resolution requires the ReferenceRoleAssignmentAnnotation type." The bulleted recap two paragraphs below the code samples then treats "Cross-environment endpoint resolution" and "RBAC auto-wiring" as separate behaviors. As a blind reader, the page contradicts itself: endpoint resolution is presented as both depending on the annotation (in the Aside) and being independent of it (in the recap). The intent appears to be that RBAC auto-wiring (not endpoint resolution) is what carries the experimental annotation; the Aside should be reworded to match. Phase A confirms the recap framing is correct.

W3 — AddAzureKubernetesEnvironment / addAzureKubernetesEnvironment introduced without context. The C# and TypeScript samples both call these APIs as the first non-trivial line, but the page never explains which package or namespace provides them, and there is no link to AKS hosting docs. A reader following the example from scratch would not know which aspire add invocation supplies the API.

W4 — "Before this fix" paragraph reads like a release note, not user-facing documentation. The paragraph at the top of the new section ("Before this fix, aspire deploy threw a 'context not found' error...") describes an internal bug history. New readers (the target audience of a reference page) never experienced the bug and may be confused why their docs page describes a regression they cannot reproduce. Consider replacing with a <Badge> or a "Version introduced" note pattern already used elsewhere on the same page, or move the historical context into the Whats New entry.

Passed checks

  • /diagnostics/aspireazure003/ and /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/ both render at HTTP 200.
  • Cross-link from aspireazure003 → /integrations/cloud/azure/azure-ai-foundry/azure-ai-foundry-host/#reference-a-hosted-agent-across-compute-environments resolves (anchor reference-a-hosted-agent-across-compute-environments is present on the target page).
  • Reverse link from the foundry Aside → /diagnostics/aspireazure003/ resolves (HTTP 200) and follows the trailing-slash convention.
  • The new headings produce unique slugs: cross-compute-environment-hosted-agent-reference on the diagnostics page and reference-a-hosted-agent-across-compute-environments on the foundry page.
  • WithRoleAssignments(...) and withFoundryRoleAssignments(...) referenced in the new prose are documented elsewhere on the same foundry page (## Configure role assignments at L1527+).
  • C# and TypeScript code blocks render with the correct language tag and Tabs/TabItem pivot syncs across the page via syncKey='aspire-lang'.

Knowledge gaps

K1 — Projects.Agent / Projects.Web type references in the C# sample. As a reader who has not used Aspire AppHost project references before, the Projects.Agent and Projects.Web generic type arguments are unexplained. This is standard Aspire convention (auto-generated project metadata) documented elsewhere, but the page assumes the reader already knows that <ProjectReference> entries in the AppHost csproj produce these types.

K2 — TypeScript import './.aspire/modules/aspire.mjs'. A reader following the TS sample as-is would need to know that aspire init (or aspire add) generates ./.aspire/modules/aspire.mjs. The page never mentions it. Consistent with other TS examples on the same page (so not a blocker for this section), but worth either a one-line note or a link to the polyglot AppHost setup guide.

Recommendations

  1. Resolve W2 by rewording the Aside so it pins ASPIREAZURE003 to RBAC auto-wiring (the actual carrier) rather than endpoint resolution.
  2. Resolve W1 by either suppressing in TypeScript with an explanatory comment or by stating in prose that ASPIREAZURE003 is .NET-only.
  3. Resolve W3 by adding a one-line callout naming the package that provides AddAzureKubernetesEnvironment.
  4. Consider W4 — replace "Before this fix" prose with a version-introduced badge or move historical context to the release notes.

- PRRT_kwDOQK_VN86F_lR0: Clarify that ReferenceRoleAssignmentAnnotation is used internally by AsHostedAgent for RBAC wiring.
- PRRT_kwDOQK_VN86F_lR2: Remove the invalid PublishAsHostedAgent diagnostic example.
- PRRT_kwDOQK_VN86F_lR4: Decouple endpoint resolution from the RBAC annotation and remove the unnecessary ASPIREAZURE003 pragma.
- PRRT_kwDOQK_VN86F_lR7: Use AsHostedAgent in the Foundry cross-environment C# sample.

Verified against microsoft/aspire@becb48e on branch release/13.4.
Edited per the doc-writer skill.

Co-authored-by: Copilot <[email protected]>
Base automatically changed from release/13.4 to main June 1, 2026 19:39
@IEvangelist
David Pine (IEvangelist) changed the base branch from main to release/13.5 June 5, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants