Skip to content

Fix Foundry run-mode project restart - #15342

Merged
Jose Perez Rodriguez (joperezr) merged 3 commits into
release/13.2from
sebros/investigate-foundry-run-provision
Mar 18, 2026
Merged

Jose Perez Rodriguez (joperezr) merged 3 commits into
release/13.2from
sebros/investigate-foundry-run-provision

Conversation

@sebastienros

Copy link
Copy Markdown
Contributor

Description

Fixes a run-mode restart failure for Foundry projects.

When a Foundry project used its default container registry, the registry resource was only added to the app model in publish mode. In run mode, the project still referenced the registry outputs during provisioning and restart, which meant the registry state was never restored or persisted. That caused restart failures such as missing proj-acr outputs and prevented Azure:Deployments:proj:* state from being written.

This change always registers the default Foundry container registry resource and adds a regression test covering run-mode registration.

Validation:

  • ./dotnet.sh test --tl:off tests/Aspire.Hosting.Azure.Tests/Aspire.Hosting.Azure.Tests.csproj -- --filter-method "*.AddProject_AddsDefaultContainerRegistryInRunMode" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
  • Reproduced with playground/FoundryAgentBasic/FoundryAgentBasic.AppHost using aspire start/stop/start
  • Confirmed proj reaches Running and user secrets now contain both Azure:Deployments:proj-acr:* and Azure:Deployments:proj:*

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
  • Does the change require an update in our Aspire docs?

Ensure the default Foundry ACR is registered in run mode so project provisioning can restore its dependent outputs on restart.

Add a regression test covering run-mode default container registry registration for Foundry projects.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings March 18, 2026 02:48
@github-actions

github-actions Bot commented Mar 18, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15342

Or

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

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

Fixes a Foundry project restart failure in run mode by ensuring the default Azure Container Registry (ACR) resource is registered in the distributed application model (so its state/outputs can be restored and persisted across stop/start).

Changes:

  • Always registers the default Foundry container registry resource (previously publish-only).
  • Adds a regression test verifying default ACR registration in run mode.

Reviewed changes

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

File Description
tests/Aspire.Hosting.Azure.Tests/FoundryExtensionsTests.cs Adds a run-mode regression test asserting the default ACR is present and wired to the project.
src/Aspire.Hosting.Foundry/Project/ProjectBuilderExtension.cs Removes publish-mode gating so the default ACR is always added to the model.

@mitchdenny

Copy link
Copy Markdown
Member

Maybe we don't enable this if we are using RunAsFoundryLocal()..?

@github-actions

Copy link
Copy Markdown
Contributor

The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
GitHub's job rerun API also reruns dependent jobs, so the retry is being tracked in the rerun attempt.
The job links below point to the failed attempt that matched the retry-safe transient failure rules.

  • Tests / Hosting.Python / Hosting.Python (windows-latest) - Failed step 'Build test project' will be retried because the job log shows a likely transient infrastructure network failure. Matched pattern: /Unable to load the service index for source https://(?:pkgs.dev.azure.com/dnceng|dnceng.pkgs.visualstudio.com)/public/_packaging//i.

Adjust the Foundry run-mode project test to expect the default container registry to be modeled in the app resources now that restart provisioning depends on it.

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

github-actions Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 4d76902:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ❌ Upload failed
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ❌ Upload failed
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ❌ Upload failed
StopWithNoRunningAppHostExitsSuccessfully ❌ Upload failed
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23228978422

Throw a clear InvalidOperationException when AddProject is combined with RunAsFoundryLocal in either order, and add tests covering both unsupported scenarios.

Co-authored-by: Copilot <[email protected]>
@sebastienros Sébastien Ros (sebastienros) added the Servicing-consider Issue for next servicing release review label Mar 18, 2026
@joperezr Jose Perez Rodriguez (joperezr) added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Mar 18, 2026
@joperezr
Jose Perez Rodriguez (joperezr) merged commit 0b31e3d into release/13.2 Mar 18, 2026
750 of 757 checks passed
@joperezr
Jose Perez Rodriguez (joperezr) deleted the sebros/investigate-foundry-run-provision branch March 18, 2026 17:56
@dotnet-policy-service dotnet-policy-service Bot added this to the 13.2 milestone Mar 18, 2026
Copilot AI pushed a commit that referenced this pull request Mar 18, 2026
* Fix Foundry run-mode project restart

Ensure the default Foundry ACR is registered in run mode so project provisioning can restore its dependent outputs on restart.

Add a regression test covering run-mode default container registry registration for Foundry projects.

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

* Update Foundry run-mode test expectation

Adjust the Foundry run-mode project test to expect the default container registry to be modeled in the app resources now that restart provisioning depends on it.

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

* Block Foundry projects on local mode

Throw a clear InvalidOperationException when AddProject is combined with RunAsFoundryLocal in either order, and add tests covering both unsupported scenarios.

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

---------

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants