Fhi.VersionApiClient 2.0.2

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

// Install Fhi.VersionApiClient as a Cake Tool
#tool nuget:?package=Fhi.VersionApiClient&version=2.0.2                

Fhi.VersionApiClient

Small client to be used in clients that needs to upload version information to the Fhi.VersionApi. This applies to components that can not be reached directly from the Fhi Azure DevOps service.

Use of this client allows the component to instead upload its version information to the Fhi Azure VersionApi service.

Setup (using No authentication)

In program.cs, add the following:

   services.AddVersionApiClient();

If you're using the Fhi.HelseId with Refit, add a section in the appsettings.json for HelseIdWebKonfigurasjon or HelseIdApiKonfigurasjon under the Apis section:

   {
     "Name": "VersionService",
     "Url": "https://versionapi-felles-fhi.azurewebsites.net/"
   }

This url can be used for both test and production.

In the program.cs locate the builder.AddHelseidRefitBuilder() and add the following line:

   .AddRefitClient<IVersionApi>(nameof(VersionService))

Usage

Create a service class that set up the system and component names, and retrieves the environment.

An example implementation can be like:

namespace Fhi.Grunndata.OppslagWeb.Services;

public interface IOppslagsWebVersionService
{
    Task UploadVersionInfo(string status="healthy");
}

public class OppslagsWebVersionService(IVersionService versionService) : IOppslagsWebVersionService
{
    const string System = "Fhi.Grunndata";
    const string Component = "OppslagWeb";
    public async Task UploadVersionInfo(string status)
    {
        var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
        if (!string.IsNullOrEmpty(environment))
            await versionService.UploadVersionInformation(environment, System, Component, status);
    }
}

Locate a suitable place in the component which is accessed at start, or regularly, like a Ping function, inject your implementation based onm OppslagsWebVersionService, and call the UploadVersionInformation method

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.2 578 11/27/2024