Skip to content

Add configurable dev tunnel idle expiration - #19987

Merged
Damian Edwards (DamianEdwards) merged 5 commits into
microsoft:mainfrom
krubenok:u/kyrubeno/dev-tunnel-expiration
Sep 10, 2026
Merged

Damian Edwards (DamianEdwards) merged 5 commits into
microsoft:mainfrom
krubenok:u/kyrubeno/dev-tunnel-expiration

Conversation

@krubenok

@krubenok Kyle Rubenok (krubenok) commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Description

Expose the devtunnel CLI's idle expiration setting without changing the default expiration policy.

  • Add nullable DevTunnelOptions.ExpirationHours and an exported WithExpiration(int expirationHours) fluent method for C# and polyglot AppHosts.
  • Pass --expiration to both create and update, so existing tunnels reused by an AppHost receive the configured period too.
  • Accept whole hours from 1 hour through 30 days, inclusive. Serialize invariantly as hours and reject values outside the supported range.
  • Omit the argument when unset, preserving service defaults for new tunnels and the configured expiration period for existing tunnels.
  • Include expiration in option logging and document C# and TypeScript usage.
var tunnel = builder.AddDevTunnel("mytunnel")
    .WithExpiration(24)
    .WithReference(web);

This is idle expiration, not a maximum hosting duration or an access-token lifetime. The devtunnel CLI reference documents the create/update option and supported range.

In Aspire with agents creating more and more work trees for inner-loop testing, I've found it very easy to hit the 10-tunnel limit for devspaces within 30 days. By exposing an optional and explicit expiration value that devtunnels support, setting that to something short is helpful at keeping things under 10 without trying to delete tunnels explicitly.

Testing

All 71 tests in Aspire.Hosting.DevTunnels.Tests pass. Coverage includes default omission, create and update arguments, reuse after a create conflict, supported boundaries, invalid option values, culture-invariant formatting, and the fluent configuration method. CLI calls are captured by the shared test fake; no live tunnel operations are required.

Generated C# and ATS API release baselines are unchanged per repository policy.

Copilot AI balanced review requested due to automatic review settings September 8, 2026 18:16
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🚀 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 -- 19987

Or

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

@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The TypeScript example uses the wrong tunnel-reference API, and the new polyglot export lacks generated-SDK coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity src/​Aspire.Hosting.DevTunnels/​DevTunnelResourceBuilderExtensions.cs — The new exported API is only invoked directly from C#, so the generated polyglot method name and…
Low severity src/​Aspire.Hosting.DevTunnels/​README.md — This TypeScript call does not expose the referenced resource through the tunnel. The generated Dev…
What changed in this PR

Adds configurable idle expiration to the run-only Dev Tunnels integration while preserving service defaults when unset.

Changes:

  • Adds validated Expiration options and fluent API.
  • Passes expiration to create and update CLI commands.
  • Adds documentation, argument tests, and snapshots.
File Description
src/​Aspire.Hosting.DevTunnels/​DevTunnelCli.cs Emits CLI expiration arguments.
src/​Aspire.Hosting.DevTunnels/​DevTunnelOptions.cs Adds validated expiration configuration.
src/​Aspire.Hosting.DevTunnels/​DevTunnelResourceBuilderExtensions.cs Adds exported fluent API.
src/​Aspire.Hosting.DevTunnels/​README.md Documents C# and TypeScript usage.
tests/​Aspire.Hosting.DevTunnels.Tests/​Aspire.Hosting.DevTunnels.Tests.csproj Enables shared Verify initialization.
tests/​Aspire.Hosting.DevTunnels.Tests/​DevTunnelExpirationTests.cs Tests expiration behavior.
tests/​Aspire.Hosting.DevTunnels.Tests/​TestDevTunnelCli.cs Captures CLI arguments and reset calls.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.ToLoggerString_IncludesExpiration.verified.txt Verifies logging output.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateTunnelAsync_WhenTunnelExists_PassesExpirationToUpdate_hours=null.verified.txt Verifies reuse without expiration.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateTunnelAsync_WhenTunnelExists_PassesExpirationToUpdate_hours=24.verified.txt Verifies reuse with expiration.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_WithNullOptions_OmitExpiration.verified.txt Verifies null-option omission.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_PassExpirationInHours_hours=null.verified.txt Verifies unset expiration.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_PassExpirationInHours_hours=1.verified.txt Verifies minimum expiration.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_PassExpirationInHours_hours=24.verified.txt Verifies day-length expiration.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_PassExpirationInHours_hours=25.verified.txt Verifies non-day whole hours.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_PassExpirationInHours_hours=720.verified.txt Verifies maximum expiration.
tests/​Aspire.Hosting.DevTunnels.Tests/​Snapshots/​DevTunnelExpirationTests.CreateAndUpdate_FormatExpirationInvariantly.verified.txt Verifies invariant formatting.

Comment thread src/Aspire.Hosting.DevTunnels/README.md Resolved
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings September 8, 2026 19:13
@krubenok

Copy link
Copy Markdown
Member Author

Regarding the dogfood instructions: no code change is needed for this informational comment; this fix uses focused local regression coverage without live tunnel operations.

Regarding the CI retry notice: no code change is needed for the retry notification itself. Required checks passed on the previous head; the polyglot review fixes are now pushed for a fresh CI run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the documented CLI contract and includes focused boundary, reuse, omission, formatting, and polyglot coverage.

Review tier: Balanced
Findings: None

Issues resolved since last review (2)
Severity Finding
Low severity src/​Aspire.Hosting.DevTunnels/​README.md — This TypeScript call does not expose the referenced resource through the tunnel. The generated Dev… View resolved comment
Medium severity src/​Aspire.Hosting.DevTunnels/​DevTunnelResourceBuilderExtensions.cs — The new exported API is only invoked directly from C#, so the generated polyglot method name and… View resolved comment

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The integer-hours fluent API conflicts with the promised TimeSpan contract and example.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity src/​Aspire.Hosting.DevTunnels/​DevTunnelResourceBuilderExtensions.cs — The PR description and its C# example promise WithExpiration(TimeSpan), but this public API…

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the documented CLI contract and includes comprehensive boundary, reuse, omission, culture, and polyglot coverage.

Review tier: Balanced
Findings: None

Issues resolved since last review (1)
Severity Finding
Medium severity src/​Aspire.Hosting.DevTunnels/​DevTunnelResourceBuilderExtensions.cs — The PR description and its C# example promise WithExpiration(TimeSpan), but this public API… View resolved comment

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@DamianEdwards
Damian Edwards (DamianEdwards) merged commit 9c2af96 into microsoft:main Sep 10, 2026
113 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.6 milestone Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ CI Failure Analysis: Possible Flaky Test(s)

The CI build failed due to test failure(s) that appear unrelated to the PR changes. These may be flaky tests.

Suspected flaky test(s):

Suggested actions:

  • Re-run the failed CI jobs to confirm if the failure is intermittent
  • If the test continues to fail, consider quarantining it using /quarantine-test <test name> <issue URL>
  • Search existing issues to see if this test is already known to be flaky

You can re-run the failed jobs from the workflow run page.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants