Skip compute env validation in run mode (#16940)#16945
Conversation
The validate-azure-container-apps and validate-azure-app-service pipeline steps run in 'before-start', which fires for both 'aspire run' and publish. In run mode, AddAzureContainerAppEnvironment/AddAzureAppServiceEnvironment do not add their environment resources to the model. Any compute resource that ends up with a PublishAs* customization annotation (for example via WithAnnotation) therefore trips the 'no environment resources' branch at 'aspire run' time, even though the user did add an environment. PublishAs* annotations only affect publish/deploy output, so skip the validation entirely when ExecutionContext.IsPublishMode is false. Fixes #16940. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16945Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16945" |
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression where aspire run could fail during the before-start pipeline phase due to Azure compute-environment validation steps running in run mode (where environment resources are intentionally not added to the model).
Changes:
- Short-circuit
validate-azure-container-appswhen not in publish mode. - Short-circuit
validate-azure-app-servicewhen not in publish mode. - Add regression tests ensuring
ExecuteBeforeStartHooksAsyncdoes not throw in run mode when compute resources carry publish-only customization annotations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppExtensions.cs | Skip Azure Container Apps environment validation when IsPublishMode is false. |
| src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs | Skip Azure App Service environment validation when IsPublishMode is false. |
| tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs | Adds run-mode regression test ensuring the container apps validation step doesn’t throw. |
| tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs | Adds run-mode regression test ensuring the app service validation step doesn’t throw. |
|
🎬 CLI E2E Test Recordings — 78 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25680681446 |
|
/backport to release/13.3 |
|
Started backporting to |
|
✅ No documentation update needed. Bug fix only — no new APIs, configuration options, or user-facing behavioral changes were introduced. The PR fixes a regression where |
Description
Fixes #16940.
After upgrading to 13.3.0,
aspire runstarted failing with:even when the user had called
AddAzureContainerAppEnvironment.Root cause
The
validate-azure-container-appsstep (introduced in #13780) is wired into thebefore-startpipeline phase, which runs for bothaspire runand publish/deploy. The step checks forAzureContainerAppEnvironmentResourceinstances in the model — butAddAzureContainerAppEnvironmentonly adds the environment resource to the model in publish mode (in run mode it returns a builder withoutAddResource). So in run mode the "no environment resources" branch is always taken, and any compute resource that ends up withAzureContainerAppCustomizationAnnotation/AzureContainerAppJobCustomizationAnnotation(e.g. attached viaWithAnnotation) trips the throw.validate-azure-app-servicehas the identical shape.Fix
PublishAs*annotations only affect publish/deploy output, so the validation has no purpose in run mode. Both validation steps now short-circuit whenctx.ExecutionContext.IsPublishModeis false.Added regression tests for both validations that build a run-mode app with a compute resource carrying the customization annotation and assert that
ExecuteBeforeStartHooksAsyncdoes not throw.Checklist