From Nomirun CLI version 1.15.0 and Nomirun Host version 1.5.0, Nomirun introduced the Nomirun Host Extensions.
This guide will help you create your own Nomirun host extension, by implementing the NomirunHostExtensionStartup abstract class.
This will allow for automatic registration of extension services and middleware.
First, create a new .NET library project, for example My.Custom.Extension.
Next add the Nomirun.Sdk.Abstractions library to the project.
<ItemGroup>
<PackageReference Include="Nomirun.Sdk.Abstractions" Version="1.0.38" />
</ItemGroup>
Create Startup.cs file and implement the NomirunHostExtensionStartup abstract class:
public class Startup : NomirunHostExtensionStartup
{
public Startup(IConfiguration configuration) : base(configuration)
{
}
protected override void RegisterHostExtensionServices(IServiceCollection services)
{
//Register services here, for example:
services.AddAuthentication().AddJwtBearer(options =>
{
options.Audience = Configuration["Audience"];
options.Authority = Configuration["Authority"];
});
}
protected override void ConfigureHostExtension(IApplicationBuilder app)
{
//Register middleware here, for example:
app.UseAuthentication();
}
}Now you can build a NuGet package of your extension and include it in Nomirun Host in any cluster you want.
Make sure you generate a SHA512 hash of your NuGet package and include it in the clusters.yaml file in the extensions section of a host:
clusters:
- name: SolarInverters
hosts:
- name: SolarInverters
...
extensions:
- name: My.Custom.Extension
version: 1.0.0
hash: 58E4E33FB1943B51FBC4A346A24012104AA92B3F2F738F8B9EF83DC6A50343389D315BFB8F51F6CB6DDAB0F13BBFE87CFFD86A4F26D0FB4686D0C273F7A8C721
Also, make sure that the My.Custom.Extension NuGet package repository is included in the nuget.config file of Nomirun CLI configuration. Run nomirun init to add a new NuGet repository if it’s missing.