Enable on-demand devtunnel for any resource via a resource command
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
Enable exposing any resource with http endpoints on-demand via a resource command if builder-level method called.
This would involve exposing a new API on `IDistributedApplicationBuilder` to enable support for exposing resource via a dev tunnel on-demand via a resource command, e.g.
```csharp
var builder = DistributedApplication.CreateBuilder();
builder.AddOnDemandDevTunnel();
builder.AddProject("web");
builder.Build().Run();
```
This would add a resource command to all resources with http endpoints in the application model that when clicked shows a dialog to select which HTTP endpoints (ports) on the resource to expose via a dev tunnel and whether the tunnel should allow anonymous access or not. After selecting the endpoints and clicking OK, tunnel resources would show up beneath the target resource.
Thoughts are this would be implemented by adding a hidden tunnel resource to the model for every resource with HTTP endpoints when `AddOnDemandDevTunnel()` is called, with the tunnel resource being a child of the target resource, along with hidden tunnel port resources for every HTTP endpoint on every resource in the model. When the resource command is invoked on a resource, the child tunnel and port resources would be shown so that it's clear that the resource is currently being exposed via a tunnel. The devtunnel instance created would be a temporary tunnel rather than a named tunnel (i.e. one started by running `devtunnel host --port-numbers `). Once the tunnel is stopped in the UI, it would disappear until the resource command is invoked again. State between invocations in a single session would be stored on the resource instances in the model. The tunnel resource would need to have its args dynamically adjusted between runs.
Contributor guide
Assessment
This issue has not been assessed yet.