Ragnarok.HostedService 2.0.0

dotnet add package Ragnarok.HostedService --version 2.0.0                
NuGet\Install-Package Ragnarok.HostedService -Version 2.0.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="Ragnarok.HostedService" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ragnarok.HostedService --version 2.0.0                
#r "nuget: Ragnarok.HostedService, 2.0.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.
// Install Ragnarok.HostedService as a Cake Addin
#addin nuget:?package=Ragnarok.HostedService&version=2.0.0

// Install Ragnarok.HostedService as a Cake Tool
#tool nuget:?package=Ragnarok.HostedService&version=2.0.0                

<div align="center"> <h1> Ragnarok </h1> </div>

Ragnarok.HostedService

By adding the NgrokHostedService to your application, ngrok tunnels will be automatically created for any local application URLs.

Installation

Install via Nuget

Usage

UseNgrok Extension

An extension method is provided on the IWebHostBuilder to setup the NgrokHostedService. Optional parameters are available that allow for defining a tunnel as well as options for managing the bahavior of the RagnarokClient.

The option to automatically download ngrok is disabled by default. It can be enabled via the options parameter.

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(x => x
            .UseStartup<Startup>()
            .UseNgrok(options => options.DownloadNgrok = true, 
                      tunnel => tunnel.WithName("weather-api")
                                      .WithOauthProvider("google")
                                      .WithDomain("cheerful-sober-mudfish.ngrok-free.app"));

Behind the scenes

On application startup, all registered server addresses are retrieved, and an ngrok client is started (if necessary). Tunnels are then dynamically created for each server address. The public url for the created tunnels can be retrieved via the ngrok Agent Api, by subscribing to the Ready event of the hosted service, or subscribing to the TunnelCreated event of the RagnarokClient. If not tunnels are defined in the yml config file, you can define a tunnel using the hosted service (as shown above) or a default tunnel will be automatically created.

Ngrok Agent Api

The NgrokHostedService is added to the applications ServiceCollection, allowing for access via Dependency Injection. It provides full access to the ngrok Agent Api via the RagnarokClient property.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 216 12/19/2023
1.0.0 429 10/5/2021
0.1.0 375 10/1/2021

Update to .Net 8 and Ngrok v3