Fhi.Common.VersionApiClient 1.0.0-beta.7

Suggested Alternatives

Fhi.VersionApiClient

This is a prerelease version of Fhi.Common.VersionApiClient.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Fhi.Common.VersionApiClient --version 1.0.0-beta.7                
NuGet\Install-Package Fhi.Common.VersionApiClient -Version 1.0.0-beta.7                
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="1.0.0-beta.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fhi.Common.VersionApiClient --version 1.0.0-beta.7                
#r "nuget: Fhi.Common.VersionApiClient, 1.0.0-beta.7"                
#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=1.0.0-beta.7&prerelease

// Install Fhi.Common.VersionApiClient as a Cake Tool
#tool nuget:?package=Fhi.Common.VersionApiClient&version=1.0.0-beta.7&prerelease                

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 net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.