Skip to content

Reference Foundry project from hosted agent target - #17687

Merged
David Fowler (davidfowl) merged 4 commits into
microsoft:mainfrom
tommasodotNET:fix/foundry-hosted-agent-target-reference
May 30, 2026
Merged

David Fowler (davidfowl) merged 4 commits into
microsoft:mainfrom
tommasodotNET:fix/foundry-hosted-agent-target-reference

Conversation

@tommasodotNET

Copy link
Copy Markdown
Contributor

Description

Publish-mode hosted agents now attach the Microsoft Foundry project reference to the actual deployment target resource after the target is resolved, instead of attaching it to the hosted-agent wrapper resource. This ensures the generated or existing container target has the Foundry project connection environment annotations before container build/deployment processing consumes the target resource.

This keeps run-mode behavior unchanged and preserves the hosted-agent wrapper's reference relationship to the deployment target. A regression test verifies the Foundry project reference is on AzureHostedAgentResource.Target and not only on the hosted-agent resource.

Validation:

./restore.sh
dotnet test --project tests/Aspire.Hosting.Foundry.Tests/Aspire.Hosting.Foundry.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17687

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17687"

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 moves Foundry project references in publish-mode hosted agents onto the resolved deployment target so container deployment processing can consume the target’s Foundry connection annotations.

Changes:

  • Adds publish-mode helper to attach the Foundry project reference to the deployment target.
  • Keeps the hosted-agent wrapper relationship to its target while removing the direct project reference from the wrapper.
  • Adds a regression test for target-level project reference placement.

Reviewed changes

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

File Description
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs Moves Foundry project reference attachment from the hosted-agent wrapper to the resolved deployment target.
tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs Adds coverage for project reference placement on the hosted-agent deployment target.

@davidfowl
David Fowler (davidfowl) force-pushed the fix/foundry-hosted-agent-target-reference branch from 9655bc6 to 694f515 Compare May 29, 2026 23:21
@davidfowl

Copy link
Copy Markdown
Collaborator

/backport to release/13.4

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/13.4 (link to workflow run)

Seed Foundry project outputs in tests that directly invoke hosted-agent environment resolution, matching the provisioning state available during deployment.

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

Copy link
Copy Markdown
Collaborator

/backport to release/13.4

1 similar comment
@davidfowl

Copy link
Copy Markdown
Collaborator

/backport to release/13.4

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/13.4 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/13.4 (link to workflow run)

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

David Fowler (@davidfowl) an error occurred while backporting to release/13.4. See the workflow output for details.

@davidfowl

Copy link
Copy Markdown
Collaborator

/backport to release/13.4

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/13.4 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@davidfowl
David Fowler (davidfowl) enabled auto-merge (squash) May 30, 2026 02:24
@davidfowl
David Fowler (davidfowl) merged commit 12c9980 into microsoft:main May 30, 2026
919 of 927 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants