DevTunnelsResourceBuilderExtensions.AddDevTunnel Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a dev tunnel resource to the application model.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.DevTunnels.DevTunnelResource> AddDevTunnel(this Aspire.Hosting.IDistributedApplicationBuilder builder, string name, string? tunnelId = default, Aspire.Hosting.DevTunnels.DevTunnelOptions? options = default);
static member AddDevTunnel : Aspire.Hosting.IDistributedApplicationBuilder * string * string * Aspire.Hosting.DevTunnels.DevTunnelOptions -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.DevTunnels.DevTunnelResource>
<Extension()>
Public Function AddDevTunnel (builder As IDistributedApplicationBuilder, name As String, Optional tunnelId As String = Nothing, Optional options As DevTunnelOptions = Nothing) As IResourceBuilder(Of DevTunnelResource)
Parameters
- builder
- IDistributedApplicationBuilder
- name
- String
- tunnelId
- String
- options
- DevTunnelOptions
Returns
Examples
The following example shows how to create a dev tunnel resource that exposes all endpoints on a web application project and enable anonymous access:
var builder = DistributedApplication.CreateBuilder(args);
var web = builder.AddProject<Projects.WebApp>("web");
var tunnel = builder.AddDevTunnel("mytunnel")
.WithReference(web)
.WithAnonymousAccess();
builder.Build().Run();
Remarks
Dev tunnels can be used to expose local endpoints to the public internet via a secure tunnel. By default, the tunnel requires authentication, but anonymous access can be enabled via WithAnonymousAccess(IResourceBuilder<DevTunnelResource>).