Fix HostUrl with container tunnel - #16684
Merged
David Negstad (danegsta) merged 2 commits intoMay 5, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16684Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16684" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes HostUrl resolution for container resources when the Aspire container tunnel is enabled, ensuring HostUrl values that correspond to app-model host endpoints are resolved via the tunnel (including async port allocation), while unmatched host-local URLs remain on the container host bridge.
Changes:
- Update
HostUrlresolution to (a) detect localhost targets robustly, (b) resolve matching host endpoints via the tunnel using the endpoint’s asyncPortproperty, and (c) keep unmatched host-local URLs on the host bridge hostname. - Treat matching
HostUrlvalues as dependencies during dependency discovery so tunnel services are created before container environment evaluation. - Add/adjust regression tests covering both the “matching host endpoint uses tunnel port” and “unmatched host-local port uses host bridge” scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/ExpressionResolverTests.cs | Updates expectations for HostUrl rewriting when tunnel is enabled but no matching app-model host endpoint exists. |
| tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs | Adds DCP regression tests for matched vs. unmatched HostUrl host-port behavior and updates test executor DI setup. |
| src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs | Extends dependency discovery to treat certain HostUrl values as resource dependencies. |
| src/Aspire.Hosting/ApplicationModel/HostUrl.cs | Updates HostUrl resolution logic to support container tunnel port allocation and adds localhost/port parsing helper. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Karol Zadora-Przylecki (karolz-ms)
approved these changes
May 4, 2026
David Negstad (danegsta)
enabled auto-merge (squash)
May 5, 2026 01:08
David Negstad (danegsta)
merged commit May 5, 2026
798d1a8
into
microsoft:main
2786 of 2843 checks passed
Member
Author
|
/backport to release/13.3 |
Contributor
|
Started backporting to |
Nell Shamrell-Harrington (nellshamrell)
pushed a commit
to nellshamrell/aspire
that referenced
this pull request
May 18, 2026
* Fix HostUrl with container tunnel Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Scope HostUrl matching to host endpoints Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #16641
Fixes #16642
This fixes
HostUrlresolution for container resources when the Aspire container tunnel is enabled.HostUrlvalues that match an app-model host endpoint as dependencies so DCP creates the corresponding container tunnel service before the container environment is resolved.HostUrlvalues through the endpoint reference's async port property instead of reading the endpoint's allocated port synchronously before tunnel allocation completes.HostUrlvalues on the container host bridge instead of rewriting them toaspire.dev.internalwhen no tunnel service backs that port.HostUrlhost-port scenarios.Validation:
dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-method "*.ContainerHostUrlMatchingHostEndpointUsesTunnelPort" --filter-method "*.ContainerHostUrlWithoutMatchingHostEndpointUsesContainerHostBridge" --filter-method "*.HostUrlPropertyGetsResolved" --filter-method "*.HostUrlPropertyGetsResolvedInOtlpExporterEndpoint" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-launch-profile -- --filter-class "*.DcpExecutorTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: