Skip to content

Fix Foundry run-mode project restart#15342

Merged
joperezr merged 3 commits intorelease/13.2from
sebros/investigate-foundry-run-provision
Mar 18, 2026
Merged

Fix Foundry run-mode project restart#15342
joperezr merged 3 commits intorelease/13.2from
sebros/investigate-foundry-run-provision

Conversation

@sebastienros
Copy link
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 <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 18, 2026 02:48
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

🚀 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"

Copy link
Contributor

Copilot AI left a comment

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
Member

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

@github-actions
Copy link
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 <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

🎬 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 <223556219+Copilot@users.noreply.github.com>
@sebastienros sebastienros requested a review from mitchdenny March 18, 2026 04:23
@sebastienros sebastienros added the Servicing-consider Issue for next servicing release review label Mar 18, 2026
@joperezr joperezr added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Mar 18, 2026
@joperezr joperezr merged commit 0b31e3d into release/13.2 Mar 18, 2026
750 of 757 checks passed
@joperezr 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 <223556219+Copilot@users.noreply.github.com>

* 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 <223556219+Copilot@users.noreply.github.com>

* 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 <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants