DevTunnels.Client
1.0.2
See the version list below for details.
dotnet add package DevTunnels.Client --version 1.0.2
NuGet\Install-Package DevTunnels.Client -Version 1.0.2
<PackageReference Include="DevTunnels.Client" Version="1.0.2" />
<PackageVersion Include="DevTunnels.Client" Version="1.0.2" />
<PackageReference Include="DevTunnels.Client" />
paket add DevTunnels.Client --version 1.0.2
#r "nuget: DevTunnels.Client, 1.0.2"
#:package DevTunnels.Client@1.0.2
#addin nuget:?package=DevTunnels.Client&version=1.0.2
#tool nuget:?package=DevTunnels.Client&version=1.0.2
DevTunnels.Client
Async-first .NET 10 client library for Azure Dev Tunnels, wrapping the devtunnel CLI with a typed, cancellation-aware API.
Packages
| Package | Description |
|---|---|
DevTunnels.Client |
Core typed CLI wrapper |
DevTunnels.Client.DependencyInjection |
IServiceCollection registration helpers |
Requirements
The devtunnel CLI must be installed. The library searches the following locations in order:
DevTunnelsClientOptions.CliPathOverride— explicit path set in codeDEVTUNNEL_CLI_PATHenvironment variable- Well-known install paths (checked by default, no PATH entry required):
- Windows —
%LOCALAPPDATA%\Microsoft\DevTunnels\,~/.devtunnels/bin/,~/bin/ - macOS —
/opt/homebrew/bin/(Homebrew),/usr/local/bin/,~/bin/ - Linux —
~/.local/bin/,~/bin/,/usr/local/bin/
- Windows —
- System
PATH
Minimum CLI version: 1.0.1435
The library enforces this at startup. If the installed CLI is older, ProbeCliAsync() returns
MeetsMinimumVersion = false and operations that require the CLI will throw.
Check your installed version:
devtunnel --version
# expected output: Tunnel CLI version: 1.0.1435+<commit>
The library was developed and integration-tested against 1.0.1435. Later versions are expected to be compatible; earlier versions are not supported.
The minimum can be overridden per-instance via
DevTunnelsClientOptions.MinimumSupportedVersionif you need to pin a different floor.
Install / update:
# Windows
winget install Microsoft.DevTunnel
# or update an existing install:
winget upgrade Microsoft.DevTunnel
# macOS
brew install devtunnel
# or update:
brew upgrade devtunnel
# Linux / other
curl -sL https://aka.ms/DevTunnelCliInstall | bash
Or follow the official install guide.
Install
dotnet add package DevTunnels.Client
dotnet add package DevTunnels.Client.DependencyInjection # optional
Quick Start
using DevTunnels.Client;
var client = new DevTunnelsClient(new DevTunnelsClientOptions
{
CommandTimeout = TimeSpan.FromSeconds(15)
});
// Check CLI is available
var probe = await client.ProbeCliAsync();
Console.WriteLine($"devtunnel {probe.Version} installed: {probe.IsInstalled}");
// Login
await client.LoginAsync(LoginProvider.GitHub);
// Create a persistent tunnel with a port
await client.CreateOrUpdateTunnelAsync("my-tunnel", new DevTunnelOptions
{
Description = "My development tunnel",
AllowAnonymous = true,
});
await client.CreateOrReplacePortAsync("my-tunnel", 5000, new DevTunnelPortOptions
{
Protocol = "http", // devtunnel terminates TLS; local service speaks plain HTTP
});
// Host the tunnel and wait for it to be ready
using var session = await client.StartHostSessionAsync(
new DevTunnelHostStartOptions { TunnelId = "my-tunnel" },
CancellationToken.None);
await session.WaitForReadyAsync(CancellationToken.None);
Console.WriteLine($"Public URL: {session.PublicUrl}");
// Keep alive until cancelled
await session.WaitForExitAsync(CancellationToken.None);
Dependency Injection
using DevTunnels.Client.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddDevTunnelsClient(options =>
{
options.CommandTimeout = TimeSpan.FromSeconds(15);
});
API Surface
Authentication
| Method | Description |
|---|---|
ProbeCliAsync() |
Check that devtunnel is installed and get its version |
GetLoginStatusAsync() |
Check current login state |
EnsureLoggedInAsync(provider?) |
Login if not already, coalescing concurrent callers |
LoginAsync(provider) |
Interactive browser login (GitHub or Microsoft) |
LogoutAsync() |
Sign out |
Tunnels
| Method | Description |
|---|---|
CreateOrUpdateTunnelAsync(id, options) |
Create or update a named tunnel |
GetTunnelAsync(id) |
Retrieve tunnel metadata |
ListTunnelsAsync() |
List all tunnels for the account |
DeleteTunnelAsync(id) |
Delete a tunnel |
Ports
| Method | Description |
|---|---|
CreateOrReplacePortAsync(tunnelId, port, options) |
Create or replace a port |
UpdatePortAsync(tunnelId, port, options) |
Update port settings in-place |
GetPortListAsync(tunnelId) |
List ports on a tunnel |
DeletePortAsync(tunnelId, port) |
Remove a port |
Access
| Method | Description |
|---|---|
GetAccessAsync(tunnelId, port?) |
Get access policies |
CreateAccessAsync(tunnelId, anonymous, deny?, port?) |
Add an access entry |
ResetAccessAsync(tunnelId, port?) |
Reset to default access |
GetAccessTokenAsync(tunnelId, scopes?) |
Issue a scoped access token |
Host Session
| Member | Description |
|---|---|
StartHostSessionAsync(options, ct) |
Start a devtunnel host process |
IDevTunnelHostSession.WaitForReadyAsync(ct) |
Wait until the public URL is available |
IDevTunnelHostSession.WaitForExitAsync(ct) |
Wait until the session ends |
IDevTunnelHostSession.PublicUrl |
Live public HTTPS URL (standard-port, no explicit port in URL) |
IDevTunnelHostSession.State |
Current session state |
IDevTunnelHostSession.OutputReceived |
Raw CLI output event stream |
IDevTunnelHostSession.StopAsync(ct) |
Gracefully stop the session |
Escape Hatch
// Run any devtunnel command and capture stdout/stderr
var result = await client.ExecuteRawAsync(["user", "show", "--json", "--nologo"]);
Console.WriteLine(result.StandardOutput);
Repository Layout
src/
DevTunnels.Client/ # core library
DevTunnels.Client.DependencyInjection/ # IServiceCollection helpers
tests/
DevTunnels.Client.Tests/ # unit tests
examples/
DevTunnels.Client.Example/ # interactive CLI sample (Spectre.Console)
Build
dotnet restore DevTunnels.Client.slnx
dotnet build DevTunnels.Client.slnx -c Release
dotnet test DevTunnels.Client.slnx -c Release --no-build
License
MIT. See LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.6)
- Microsoft.Extensions.Options (>= 10.0.6)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.6)
- Microsoft.Extensions.Options (>= 10.0.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DevTunnels.Client:
| Package | Downloads |
|---|---|
|
DevTunnels.Client.DependencyInjection
IServiceCollection registration helpers for DevTunnels.Client. Adds IDevTunnelsClient as a singleton via AddDevTunnelsClient() with AOT-safe Action<T> configuration or reflection-based IConfiguration binding. |
GitHub repositories
This package is not used by any popular GitHub repositories.