Skip to content

Upgrade HTTP endpoints to HTTPS in Azure App Service#16060

Merged
davidfowl merged 3 commits intomainfrom
davidfowl/appsvc-https
Apr 12, 2026
Merged

Upgrade HTTP endpoints to HTTPS in Azure App Service#16060
davidfowl merged 3 commits intomainfrom
davidfowl/appsvc-https

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

Description

Upgrade HTTP endpoints to HTTPS in Azure App Service, mirroring the existing behavior in Azure Container Apps (added in #14267).

Azure App Service already forces HTTP to HTTPS redirect at the platform level (docs), so connection strings should use https:// to match the actual serving scheme. Previously, HTTP endpoints kept http:// in their connection strings, which was inconsistent with reality.

Changes:

  • HTTP endpoints are now upgraded to HTTPS:443 by default
  • Add WithHttpsUpgrade(false) to opt out at the environment level
  • Consolidated HTTPS upgrade logging (one message per environment listing all affected endpoints)
  • New test for opt-out behavior

This matches the ACA implementation 1:1 in API shape, naming, and behavior.

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?

HTTP endpoints are now upgraded to HTTPS:443 by default in App Service,
matching the existing behavior in Azure Container Apps. App Service already
redirects HTTP to HTTPS at the platform level, so this ensures connection
strings reflect the actual serving scheme.

- Add PreserveHttpEndpoints property to AzureAppServiceEnvironmentResource
- Add WithHttpsUpgrade() extension method to opt out
- Upgrade HTTP->HTTPS in ProcessEndpoints with consolidated logging
- Add CanPreserveHttpSchemeUsingWithHttpsUpgrade test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 11, 2026 07:08
@github-actions
Copy link
Copy Markdown
Contributor

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

Or

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

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

Updates Azure App Service publishing to automatically upgrade HTTP endpoint references to HTTPS:443 (matching the existing Azure Container Apps behavior), with an environment-level opt-out via WithHttpsUpgrade(false) and consolidated logging.

Changes:

  • Upgrade App Service HTTP endpoint mappings to https:// + port 443 by default, with an environment opt-out (WithHttpsUpgrade(false)).
  • Add environment-scoped aggregation + single log message listing upgraded endpoints.
  • Update/extend Azure App Service publishing snapshot tests to reflect the new endpoint scheme behavior.
Show a summary per file
File Description
src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs Applies HTTPS upgrade (unless opted out) when building endpoint mappings used for endpoint references.
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs Adds environment flag (PreserveHttpEndpoints) to control upgrade behavior.
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs Introduces WithHttpsUpgrade(bool upgrade = true) public API to toggle upgrade behavior.
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentContext.cs Aggregates upgraded endpoints and logs once per environment.
src/Aspire.Hosting.Azure.AppService/AzureAppServiceInfrastructure.cs Invokes the consolidated HTTPS-upgrade log after processing resources.
tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs Adds a new test intended to cover opt-out behavior.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.EndpointReferencesAreResolvedAcrossProjects.verified.bicep Updates expected connection string scheme to https:// for App Service.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddAppServiceWithTargetPort.verified.bicep Updates expected connection string scheme to https://.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddAppServiceWithArgs.verified.bicep Updates expected connection string scheme to https://.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddAppServiceToEnvironmentWithoutDashboard.verified.bicep Updates expected connection string scheme to https://.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.CanPreserveHttpSchemeUsingWithHttpsUpgrade.verified.json Adds snapshot output for the new opt-out test.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.CanPreserveHttpSchemeUsingWithHttpsUpgrade.verified.bicep Adds snapshot output for the new opt-out test.

Copilot's findings

  • Files reviewed: 12/12 changed files
  • Comments generated: 3

Comment thread tests/Aspire.Hosting.Azure.Tests/AzureAppServiceTests.cs Outdated
Mirror the ACA WithHttpsUpgrade documentation pattern with remarks
explaining opt-out behavior and a usage example.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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.

@davidfowl
Copy link
Copy Markdown
Contributor Author

/deployment-test

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #16060...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot had a problem deploying to deployment-testing April 11, 2026 14:40 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 11, 2026 14:40 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

Deployment E2E Tests failed — 23 passed, 7 failed, 0 cancelled

View test results and recordings

View workflow run

Test Result Recording
Deployment.EndToEnd-VnetSqlServerConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-NspStorageKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCompactNamingDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureStorageDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AuthenticationTests ✅ Passed
Deployment.EndToEnd-AzureLogAnalyticsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureEventHubsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AppServiceReactDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureServiceBusDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureContainerRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureAppConfigDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCustomRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaDeploymentErrorOutputTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterWithRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaExistingRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptVnetSqlServerInfraDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-PythonFastApiDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-TypeScriptExpressDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AppServicePythonDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AcaManagedRedisDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AcaCompactNamingUpgradeDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AcrPurgeTaskDeploymentTests ❌ Failed ▶️ View Recording

Copy link
Copy Markdown
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean implementation that mirrors the ACA HTTPS upgrade behavior 1:1. Scheme upgrade logic, port assignment, logging consolidation, and public API surface all look correct. No issues found.

…t URLs

Add a second project that references project1 so the snapshot captures
the resolved endpoint URLs (services__project1__http__0). This proves
WithHttpsUpgrade(false) actually preserves http:// scheme instead of
upgrading to https://.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 68 recordings uploaded (commit e1ec595)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AllPublishMethodsBuildDockerImages ▶️ 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
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ 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
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
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ 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 #24298642695

@davidfowl davidfowl merged commit 442d45d into main Apr 12, 2026
279 checks passed
@joperezr joperezr added this to the 13.3 milestone Apr 14, 2026
radical pushed a commit that referenced this pull request Apr 14, 2026
* Upgrade HTTP endpoints to HTTPS in Azure App Service

HTTP endpoints are now upgraded to HTTPS:443 by default in App Service,
matching the existing behavior in Azure Container Apps. App Service already
redirects HTTP to HTTPS at the platform level, so this ensures connection
strings reflect the actual serving scheme.

- Add PreserveHttpEndpoints property to AzureAppServiceEnvironmentResource
- Add WithHttpsUpgrade() extension method to opt out
- Upgrade HTTP->HTTPS in ProcessEndpoints with consolidated logging
- Add CanPreserveHttpSchemeUsingWithHttpsUpgrade test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add remarks and example to WithHttpsUpgrade XML docs

Mirror the ACA WithHttpsUpgrade documentation pattern with remarks
explaining opt-out behavior and a usage example.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix CanPreserveHttpSchemeUsingWithHttpsUpgrade test to verify endpoint URLs

Add a second project that references project1 so the snapshot captures
the resolved endpoint URLs (services__project1__http__0). This proves
WithHttpsUpgrade(false) actually preserves http:// scheme instead of
upgrading to https://.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants