DevTunnels.Client.DependencyInjection
0.1.0
dotnet add package DevTunnels.Client.DependencyInjection --version 0.1.0
NuGet\Install-Package DevTunnels.Client.DependencyInjection -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.DependencyInjection" 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.DependencyInjection" Version="0.1.0" />
<PackageReference Include="DevTunnels.Client.DependencyInjection" />
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.DependencyInjection --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DevTunnels.Client.DependencyInjection, 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.DependencyInjection@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.DependencyInjection&version=0.1.0
#tool nuget:?package=DevTunnels.Client.DependencyInjection&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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
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 | Versions 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.
-
net10.0
- DevTunnels.Client (>= 0.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options (>= 10.0.5)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 79 | 3/13/2026 |