Fhi.Common.VersionApiClient 2.0.1

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

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

Fhi.Common.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.1 8 11/21/2024
2.0.0 236 11/15/2024
1.0.0 63 11/15/2024
1.0.0-beta.7 4,446 3/21/2024
1.0.0-beta.6 60 3/21/2024
1.0.0-beta.5 64 3/21/2024
1.0.0-beta.4 135 3/19/2024
1.0.0-beta.3 61 3/18/2024
1.0.0-beta.2 86 3/12/2024
1.0.0-beta.1 63 3/12/2024