Skip to content

Ensure compute environment prepare waits for validation - #16580

Merged
Eric Erhardt (eerhardt) merged 2 commits into
mainfrom
eerhardt/compute-environment-fixes
Apr 29, 2026
Merged

Ensure compute environment prepare waits for validation#16580
Eric Erhardt (eerhardt) merged 2 commits into
mainfrom
eerhardt/compute-environment-fixes

Conversation

@eerhardt

Copy link
Copy Markdown
Member

When Foundry is used with another compute environment, the compute environments get confused about who takes ownership of which compute.

Make all compute-environment prepare pipeline steps depend on the shared validate-compute-environments step so before-start cannot race environment validation.

Add diagnostics coverage for a mixed Foundry hosted-agent and Azure Container Apps app.

Cover deployment target lookup returning null for a different compute environment.

When Foundry is used with another compute environment, the compute environments get confused about who takes ownership of which compute.

Make all compute-environment prepare pipeline steps depend on the shared validate-compute-environments step so before-start cannot race environment validation.

Add diagnostics coverage for a mixed Foundry hosted-agent and Azure Container Apps app.

Cover deployment target lookup returning null for a different compute environment.
@github-actions

github-actions Bot commented Apr 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 -- 16580

Or

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

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 addresses a publish/deploy pipeline race where compute-environment “prepare” steps could run in parallel with compute-environment validation, leading to ambiguous ownership when multiple compute environments (e.g., Foundry + ACA/App Service) are present.

Changes:

  • Introduces a well-known pipeline step name for validate-compute-environments and uses it in the core pipeline definition.
  • Makes compute-environment “prepare” steps depend on validate-compute-environments, ensuring validation completes before prepare can materialize deployment targets.
  • Adds/updates tests and snapshots, including diagnostics coverage for a mixed Foundry hosted-agent + Azure Container Apps scenario, and adds a null-return case for deployment-target lookup with a mismatched compute environment.

Reviewed changes

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

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/ResourceExtensionsTests.cs Adds a unit test ensuring deployment-target lookup returns null when the requested compute environment doesn’t match the annotation’s compute environment.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithRedisAccessKeyAuthentication_CreatesCorrectDependencies.verified.txt Updates expected pipeline diagnostics to reflect prepare-* depending on validate-compute-environments.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithPrivateEndpoints_CreatesCorrectDependencies.verified.txt Updates expected dependency graph ordering/dependencies to include validate-compute-environments as a prerequisite for prepare.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithMultipleComputeEnvironments_Works_step=diagnostics.verified.txt Updates multi-environment diagnostics snapshot to show validation preceding prepare steps.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithFoundryAndAzureContainerApps_CreatesCorrectDependencies.verified.txt Adds a new diagnostics snapshot for mixed Foundry + ACA compute environments.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithAzureResourceDependencies_DoesNotHang_step=diagnostics.verified.txt Updates snapshot to reflect new dependency from prepare to compute-environment validation.
tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs Adds an integration-style diagnostics test for Foundry hosted-agent + ACA to validate step graph dependencies.
src/Aspire.Hosting/Pipelines/WellKnownPipelineSteps.cs Adds ValidateComputeEnvironments constant for consistent step naming.
src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs Switches the validate step name from a literal to the new well-known constant.
src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs Updates GetDeploymentTargetAnnotation to return null when a requested compute environment doesn’t match the annotation’s compute environment.
src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentResource.cs Makes Kubernetes prepare-deployment-targets step depend on compute-environment validation.
src/Aspire.Hosting.Foundry/Project/ProjectResource.cs Makes Foundry project prepare step depend on compute-environment validation.
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs Ensures hosted-agent published resources are explicitly bound to the Foundry project compute environment.
src/Aspire.Hosting.Foundry/HostedAgent/AzureHostedAgentResource.cs Removes IComputeResource from AzureHostedAgentResource’s implemented interfaces.
src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs Makes Docker Compose prepare steps depend on compute-environment validation.
src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.cs Makes AKS prepare step depend on compute-environment validation.
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs Makes App Service environment prepare step depend on compute-environment validation.
src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs Makes ACA environment prepare step depend on compute-environment validation.
playground/FoundryAgents/FoundryAgents.AppHost/FoundryAgents.AppHost.csproj Adds AppContainers hosting package reference for the updated playground scenario.
playground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs Updates playground to include an ACA environment and bind a project to it alongside Foundry usage.

Comment thread src/Aspire.Hosting/Pipelines/WellKnownPipelineSteps.cs
Comment thread src/Aspire.Hosting.Foundry/HostedAgent/AzureHostedAgentResource.cs
Comment thread src/Aspire.Hosting/Pipelines/WellKnownPipelineSteps.cs
@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.

@eerhardt
Eric Erhardt (eerhardt) enabled auto-merge (squash) April 29, 2026 23:18
@eerhardt

Copy link
Copy Markdown
Member Author

/backport to release/13.3

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/13.3 (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.

@eerhardt
Eric Erhardt (eerhardt) merged commit fff2f6f into main Apr 29, 2026
564 of 567 checks passed
@github-actions github-actions Bot added this to the 13.4 milestone Apr 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 76 recordings uploaded (commit d400f66)

View all recordings
Status 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
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ 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
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25138492717

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

No documentation PR is required for this change.

This PR is a bug fix that ensures compute-environment prepare pipeline steps wait for the shared validate-compute-environments step before proceeding, preventing a race condition when mixing compute environments (e.g., Foundry + Azure Container Apps). The changes are internal pipeline coordination fixes with no new public APIs, new configuration options, or user-facing behavioral changes that would require documentation updates.

Generated by PR Documentation Check for issue #16580 · ● 264.1K ·

Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
)

* Ensure compute environment prepare waits for validation

When Foundry is used with another compute environment, the compute environments get confused about who takes ownership of which compute.

Make all compute-environment prepare pipeline steps depend on the shared validate-compute-environments step so before-start cannot race environment validation.

Add diagnostics coverage for a mixed Foundry hosted-agent and Azure Container Apps app.

Cover deployment target lookup returning null for a different compute environment.

* Fix tests
@github-actions github-actions Bot locked and limited conversation to collaborators May 30, 2026
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.

3 participants