Aspire.Hosting.DevTunnels
13.1.0
Prefix Reserved
dotnet add package Aspire.Hosting.DevTunnels --version 13.1.0
NuGet\Install-Package Aspire.Hosting.DevTunnels -Version 13.1.0
<PackageReference Include="Aspire.Hosting.DevTunnels" Version="13.1.0" />
<PackageVersion Include="Aspire.Hosting.DevTunnels" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting.DevTunnels" />
paket add Aspire.Hosting.DevTunnels --version 13.1.0
#r "nuget: Aspire.Hosting.DevTunnels, 13.1.0"
#:package Aspire.Hosting.DevTunnels@13.1.0
#addin nuget:?package=Aspire.Hosting.DevTunnels&version=13.1.0
#tool nuget:?package=Aspire.Hosting.DevTunnels&version=13.1.0
Aspire.Hosting.DevTunnels library
Provides extension methods and resource definitions for an Aspire AppHost to expose local application endpoints publicly via a secure dev tunnel.
Dev tunnels are useful for:
- Sharing a running local service (e.g., a Web API) with teammates, mobile devices, or webhooks.
- Testing incoming callbacks from external SaaS systems (GitHub / Stripe / etc.) without deploying.
- Quickly publishing a temporary, TLS‑terminated endpoint during development.
By default tunnels require authentication and are available only to the user who created them. You can selectively enable anonymous (public) access per tunnel or per individual port.
Getting started
Install the package
In your AppHost project, install the Aspire.Hosting.DevTunnels library via NuGet:
dotnet add package Aspire.Hosting.DevTunnels
Or using the Aspire CLI:
aspire add devtunnels
Install the devtunnel CLI
Before you create a dev tunnel, you first need to download and install the devtunnel CLI (Command Line Interface) tool that corresponds to your operating system. See the devtunnel CLI installation documentation for more details.
Basic usage
Expose all endpoints on a project
var builder = DistributedApplication.CreateBuilder(args);
var web = builder.AddProject<Projects.WebApp>("web");
var tunnel = builder.AddDevTunnel("mytunnel")
.WithReference(web);
builder.Build().Run();
Enable anonymous (public) access
var tunnel = builder.AddDevTunnel("publicapi")
.WithReference(web)
.WithAnonymousAccess(); // Entire tunnel (all ports) can be accessed anonymously
Expose only specific endpoint(s)
var web = builder.AddProject<Projects.WebApp>("web");
var tunnel = builder.AddDevTunnel("apitunnel")
.WithReference(web.GetEndpoint("api")); // Only expose the "api" endpoint
Per‑port anonymous access
You can control anonymous access at the port (endpoint) level using the overload of WithReference that accepts a bool allowAnonymous parameter:
var api = builder.AddProject<Projects.ApiService>("api");
var tunnel = builder.AddDevTunnel("mixedaccess")
.WithReference(api.GetEndpoint("public"), allowAnonymous: true)
.WithReference(api.GetEndpoint("admin")); // This endpoint requires authentication
Custom tunnel ID, description, and labels
var options = new DevTunnelOptions
{
Description = "Shared QA validation tunnel",
Labels = { "qa", "validation" },
AllowAnonymous = false
};
var tunnel = builder.AddDevTunnel(
name: "qa",
tunnelId: "qa-shared",
options: options)
.WithReference(api);
Multiple tunnels for different audiences
var web = builder.AddProject<Projects.WebApp>("web");
var publicTunnel = builder.AddDevTunnel("public")
.WithReference(web)
.WithAnonymousAccess();
var privateTunnel = builder.AddDevTunnel("private")
.WithReference(web); // Requires authentication
Service discovery integration
When another resource references a dev tunnel via:
builder.AddProject<Projects.ClientApp>("client")
.WithReference(web, publicTunnel); // Use the tunneled address for 'web'
Environment variables are injected after the tunnel port is allocated using the Aspire service discovery configuration format:
services__{ResourceName}__{EndpointName}__0 = https://{public-host}/
Example:
services__web__https__0 = https://myweb-1234.westeurope.devtunnels.ms/
This lets downstream resources use the tunneled address exactly like any other Aspire service discovery entry. Note that dev tunnels are a development time concern only and are not included when publishing or deploying an Aspire AppHost, including any service discovery information.
Referencing a tunnel delays the consumer resource's start until the tunnel has started and its endpoint is fully allocated.
Anonymous access options
| Scope | How to enable | Notes |
|---|---|---|
| Entire tunnel | tunnel.WithAnonymousAccess() |
Affects all ports unless overridden at port level. |
| Specific port(s) | WithReference(endpoint, allowAnonymous: true) |
Fine-grained control per exposed endpoint. |
If neither is set, the tunnel is private and authentication as the tunnel creator is required.
Protocol handling
DevTunnelPortOptions.Protocol supports:
httphttpsauto(let the service decide)null(default = use the referenced endpoint's scheme)
Unsupported schemes (e.g., non-HTTP(S)) will throw an exception.
Tunnel logging and diagnostics
When dev tunnel ports are successfully allocated, they log detailed information about their forwarding configuration and access level. This helps you understand which URLs are available and their security settings.
Port forwarding logs
Each port resource logs its forwarding configuration when it becomes available:
Forwarding from https://37tql9l1-7023.usw2.devtunnels.ms to https://localhost:7023/ (webfrontend/https)
Anonymous access logging
Port resources also log their effective anonymous access policy, showing both the current access level and the configuration that led to it:
When anonymous access is allowed:
!! Anonymous access is allowed (port explicitly allows it) !!
!! Anonymous access is allowed (inherited from tunnel) !!
When anonymous access is denied:
Anonymous access is not allowed (tunnel does not allow it and port does not explicitly allow or deny it)
Anonymous access is not allowed (tunnel allows it but port explicitly denies it)
The logging helps you verify that your tunnel configuration is working as expected and troubleshoot access issues.
Security considerations
- Prefer authenticated tunnels during normal development.
- Only enable anonymous access for endpoints that are safe to expose publicly.
- Treat public tunnel URLs as temporary & untrusted (rate limit / validate input server-side).
Additional documentation
Feedback & contributing
https://github.com/dotnet/aspire
Contributions (improvements, clarifications, samples) are welcome.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Aspire.Hosting (>= 13.1.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Google.Protobuf (>= 3.33.0)
- Grpc.AspNetCore (>= 2.71.0)
- Grpc.Net.ClientFactory (>= 2.71.0)
- Grpc.Tools (>= 2.72.0)
- Humanizer.Core (>= 2.14.1)
- JsonPatch.Net (>= 3.3.0)
- KubernetesClient (>= 18.0.5)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.22)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.1)
- Microsoft.Extensions.Hosting (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Primitives (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.4)
- Polly.Core (>= 8.6.4)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.22.23)
- System.IO.Hashing (>= 9.0.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aspire.Hosting.DevTunnels:
| Package | Downloads |
|---|---|
|
Aspire.Hosting.Maui
MAUI integration for Aspire (local dev only) |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 13.1.0 | 9,265 | 12/17/2025 | |
| 13.0.2-preview.1.25603.5 | 2,343 | 12/4/2025 | |
| 13.0.1-preview.1.25575.3 | 1,582 | 11/26/2025 | |
| 13.0.0-preview.1.25560.3 | 7,307 | 11/11/2025 | |
| 9.5.2-preview.1.25522.3 | 3,958 | 10/23/2025 | |
| 9.5.1-preview.1.25502.11 | 3,129 | 10/3/2025 | |
| 9.5.0-preview.1.25474.7 | 4,997 | 9/25/2025 |