Prototype for .NET Aspire DevTunnel Feature
- .NET Aspire (9.2.0)
- DevTunnels CLI (install)
AspireDevTunnels.AppHost/Program.cs
// Creation of Dev Tunnel Resource
IResourceBuilder<DevTunnelResource> devTunnelResource = builder
.AddDevTunnel("aspire-tunnel")
.WithExplicitStart(); // Remove this line for auto-start
IResourceBuilder<ProjectResource> apiService =
builder.AddProject<Projects.AspireDevTunnels_ApiService>("apiservice")
.WithDevTunnel(devTunnelResource); // Add Service Port to DevTunnel
devtunnel user login
Dashboard
Console Logs
OpenApi Spec Behind Tunnel
Dashboard Actions
- Make Tunnel Endpoints Public
- Get Active Port URLs
- Get Auth Token
Health Checks
Create Tunnel
devtunnel create sample-devtunnel-api --json
:
{
"tunnel": {
"tunnelId": "sample-devtunnel-api.usw2",
"hostConnections": 0,
"clientConnections": 0,
"labels": [],
"tunnelExpiration": "30 days",
"description": "",
"currentUploadRate": "0 MB/s (limit: 20 MB/s)",
"currentDownloadRate": "0 MB/s (limit: 20 MB/s)",
"accessControl": []
}
}
Add Port
devtunnel port add -p 1234 --protocol https --json
:
{
"port": {
"tunnelId": "sample-devtunnel-api.usw2",
"portNumber": 1234,
"protocol": "https",
"accessControl": [],
"clientConnections": 0
}
}
Get Auth Token
devtunnel token sample-devtunnel-api --scopes connect --json
{
"tunneldId": "sample-devtunnel-api.usw2",
"ports": [],
"scope": "connect",
"lifeTime": "1.00:00:00",
"expiration": "2025-04-17 20:35:16 UTC",
"token": "eyJhbGciOiJFUzI1N..."
}
Verify User Logged In
devtunnel user show --json
{
"status": "Logged in",
"provider": "microsoft",
"username": "<user emal>",
"tenantId": "<tenant id>",
"objectId": "<user object id>"
}
Verify installed
devtunnel --version
Tunnel CLI version: 1.0.1435+d49a94cc24
Tunnel service URI : https://global.rel.tunnels.api.visualstudio.com/
Tunnel service version : 1.0.1427.13095 (2733b94cde; 2025-04-02 01:00:45Z)
Tunnel service cluster : usw2