DevTunnels.Client 0.1.0

dotnet add package DevTunnels.Client --version 0.1.0
                    
NuGet\Install-Package DevTunnels.Client -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DevTunnels.Client" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevTunnels.Client" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DevTunnels.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevTunnels.Client --version 0.1.0
                    
#r "nuget: DevTunnels.Client, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DevTunnels.Client@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevTunnels.Client&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DevTunnels.Client&version=0.1.0
                    
Install as a Cake Tool

DevTunnels.Client

Async-first .NET 10 client library for Azure Dev Tunnels, wrapping the devtunnel CLI with a typed, cancellation-aware API.

Build License: MIT

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:

  1. DevTunnelsClientOptions.CliPathOverride — explicit path set in code
  2. DEVTUNNEL_CLI_PATH environment variable
  3. 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/
  4. System PATH

Install:

# Windows
winget install Microsoft.DevTunnel

# macOS
brew install 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 Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
0.1.0 93 3/13/2026