Skip to content

Add Region to DevTunnelOptions to ensure setting region devtunnel is created in#14112

Open
kola-tm wants to merge 5 commits intodotnet:mainfrom
kola-tm:dev-tunnel-region
Open

Add Region to DevTunnelOptions to ensure setting region devtunnel is created in#14112
kola-tm wants to merge 5 commits intodotnet:mainfrom
kola-tm:dev-tunnel-region

Conversation

@kola-tm
Copy link

@kola-tm kola-tm commented Jan 24, 2026

Description

Updated DevTunnelOptions with region property. This is used to set the dev tunnel region at creation, and to refer to the correct dev tunnel using the fully qualified tunnel Id. Updated readme for scenario. Please see linked issue for full context.

Fixes #14111

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?

…he dev tunnel region at creation, and to refer to the correct dev tunnel using the fully qualified tunnel Id. Updated readme for scenario
@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14112

Or

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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 24, 2026
@kola-tm
Copy link
Author

kola-tm commented Jan 24, 2026

@dotnet-policy-service agree

@kola-tm kola-tm changed the title Add Region to DevTunnelOptions to ensure setting region devtunnel is created in, and using fully qualified tunnel Id Add Region to DevTunnelOptions to ensure setting region devtunnel is created in Jan 29, 2026
@kola-tm
Copy link
Author

kola-tm commented Jan 29, 2026

@mitchdenny Hi Mitch, not too sure how to request reviewers for this PR. I saw a previous Dev Tunnel PR that was reviewed by yourself so thought to tag you in this PR.

Mitch Denny and others added 2 commits January 29, 2026 12:52
…ent regions

- Remove DI singleton registration of DevTunnelOptions
- Restore options parameter to CreateTunnelAsync method
- Add ResolvedTunnelId property to DevTunnelResource for region-qualified IDs
- Update callers to use ResolvedTunnelId for CLI operations
- Keep the Region and RegionCode additions from original PR

This preserves the original architecture where options are stored per-resource
and passed through method calls, which correctly supports multiple tunnels
with different region configurations.
@kola-tm
Copy link
Author

kola-tm commented Jan 29, 2026

@mitchdenny Thank you for looking into that. I forgot there can be many resources of the same type, and as you correctly noticed the singleton option breaks that. Much appreciated!

@kola-tm
Copy link
Author

kola-tm commented Jan 30, 2026

@afscrome Hi will you be able to assist in applying the correct tags area-integrations, devtunnels. Also should I wait for a reviewer or shall I tag a person to be added as a reviewer? Possibly Damian Edwards or Mitch Denny

@kola-tm
Copy link
Author

kola-tm commented Feb 3, 2026

@aspire/area-integrations


var rb = builder.AddResource(tunnelResource)
.WithArgs("host", tunnelId, "--nologo")
.WithArgs("host", tunnelResource.ResolvedTunnelId, "--nologo")
Copy link
Member

Choose a reason for hiding this comment

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

Just calling out that changing region creates a whole new tunnel as it impacts the ID. If someone first creates a tunnel without a reason, then updates their AppHost to specify a region, the ID of the tunnel changes and as such the previous tunnel is "orphaned" and a new tunnel is created. I don't think this is an issue per se, just calling it out. We might want to add a note to the doc comments on the appropriate methods/properties to clarify that setting/changing a region changes the tunnel ID.

Copy link
Author

Choose a reason for hiding this comment

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

So if a user omits the region option the dev tunnel CLI will pick a region with the lowest ping. If the user did proceed to add the region option, which happens to be the same region the original dev tunnel was created in, it will successfully connect to it. However if the region is not the same, then as you have stated a new dev tunnel will be created in the target region. The user will always have the option if they want to connect to the original dev tunnel to select the appropriate region.

kola-tm and others added 2 commits February 20, 2026 20:46
Co-authored-by: Damian Edwards <damian@damianedwards.com>
Co-authored-by: Damian Edwards <damian@damianedwards.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Devtunnel] Aspire.Hosting.DevTunnels - Add Region option to DevTunnelOptions

3 participants