Skip to content

Skip compute env validation in run mode (#16940)#16945

Merged
eerhardt merged 2 commits into
mainfrom
eerhardt/fix-16940-aca-validation-run-mode
May 11, 2026
Merged

Skip compute env validation in run mode (#16940)#16945
eerhardt merged 2 commits into
mainfrom
eerhardt/fix-16940-aca-validation-run-mode

Conversation

@eerhardt
Copy link
Copy Markdown
Member

Description

Fixes #16940.

After upgrading to 13.3.0, aspire run started failing with:

Step 'validate-azure-container-apps' failed: Resource '...' is configured to publish as an Azure Container App, but there are no 'AzureContainerAppEnvironmentResource' resources. Ensure you have added one by calling 'AddAzureContainerAppEnvironment'.

even when the user had called AddAzureContainerAppEnvironment.

Root cause

The validate-azure-container-apps step (introduced in #13780) is wired into the before-start pipeline phase, which runs for both aspire run and publish/deploy. The step checks for AzureContainerAppEnvironmentResource instances in the model — but AddAzureContainerAppEnvironment only adds the environment resource to the model in publish mode (in run mode it returns a builder without AddResource). So in run mode the "no environment resources" branch is always taken, and any compute resource that ends up with AzureContainerAppCustomizationAnnotation / AzureContainerAppJobCustomizationAnnotation (e.g. attached via WithAnnotation) trips the throw.

validate-azure-app-service has 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 when ctx.ExecutionContext.IsPublishMode is false.

Added regression tests for both validations that build a run-mode app with a compute resource carrying the customization annotation and assert that ExecuteBeforeStartHooksAsync does not throw.

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

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>
Copilot AI review requested due to automatic review settings May 11, 2026 15:39
@eerhardt eerhardt requested a review from mitchdenny as a code owner May 11, 2026 15:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16945

Or

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

@eerhardt eerhardt requested a review from davidfowl May 11, 2026 15:39
Copy link
Copy Markdown
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

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-apps when not in publish mode.
  • Short-circuit validate-azure-app-service when not in publish mode.
  • Add regression tests ensuring ExecuteBeforeStartHooksAsync does 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.

@eerhardt eerhardt requested a review from danegsta as a code owner May 11, 2026 15:44
@eerhardt eerhardt changed the title Skip Azure compute env validation in run mode (#16940) Skip compute env validation in run mode (#16940) May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 78 recordings uploaded (commit 982d77d)

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
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ 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
DeployK8sWithExternalHelmChart ▶️ 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
LatestCliCanStartStableChannelAppHost ▶️ View Recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ 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
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25680681446

@eerhardt eerhardt merged commit 5674ab0 into main May 11, 2026
573 of 577 checks passed
@eerhardt
Copy link
Copy Markdown
Member Author

/backport to release/13.3

@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

✅ 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 aspire run incorrectly threw a validation error about missing Azure Container App/App Service environment resources in run mode. Existing docs already correctly describe AddAzureContainerAppEnvironment and the publish/deploy workflow; no documentation update is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error after upgrade to 13.3.0

3 participants