Altinn.AspNet.HealthChecks.Warmup 0.3.0

dotnet add package Altinn.AspNet.HealthChecks.Warmup --version 0.3.0
                    
NuGet\Install-Package Altinn.AspNet.HealthChecks.Warmup -Version 0.3.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="Altinn.AspNet.HealthChecks.Warmup" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Altinn.AspNet.HealthChecks.Warmup" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Altinn.AspNet.HealthChecks.Warmup" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Altinn.AspNet.HealthChecks.Warmup --version 0.3.0
                    
#r "nuget: Altinn.AspNet.HealthChecks.Warmup, 0.3.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.
#:package Altinn.AspNet.HealthChecks.Warmup@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Altinn.AspNet.HealthChecks.Warmup&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Altinn.AspNet.HealthChecks.Warmup&version=0.3.0
                    
Install as a Cake Tool

Altinn.AspNet.HealthChecks.Warmup

Experimental — pre-1.0.0. APIs may change without notice before the 1.0.0 release.

Startup warmup companion package to Altinn.AspNet.HealthChecks: keeps /health/readiness returning 503 until your app has warmed up (JIT the ORM model, open the DB pool, prime caches), so an instance is not sent traffic before it is ready — without failing liveness and getting killed.

Usage

using Altinn.AspNet.HealthChecks.Warmup;

builder.Services.AddWarmup(builder.Configuration.GetSection("Warmup"), warmup =>
{
    warmup.AddPhase("db-pool", async (sp, ct) =>
    {
        await using var conn = await sp.GetRequiredService<NpgsqlDataSource>().OpenConnectionAsync(ct);
        // ...
    },
    // Optional per-phase budget, so one slow phase cannot consume the whole run.
    timeoutSeconds: 15);

    warmup.AddPhase("prime-search", (sp, ct) => Prime(sp, ct), optional: true); // failure won't fail readiness
});
{ "Warmup": { "Enabled": true, "TimeoutSeconds": 60 } }

Enabled and TimeoutSeconds bind from the section you pass; phases are always code. You supply the section yourself — the package never invents a key name, because an Altinn app's configuration may come from Azure App Configuration, where a section absent from every appsettings.json is not evidence the key is unset. There is also an AddWarmup(warmup => …) overload with no configuration.

Phases run in order on startup, sharing a single DI scope created for the warmup run. Non-optional phase failure → readiness Unhealthy; optional: true phases log-and-continue.

TimeoutSeconds (default 60) is the budget for the whole run. A phase-level timeoutSeconds: is layered underneath it: without one, a slow optional phase can eat the entire run budget and starve a later required phase, which then fails readiness while naming the wrong phase. Both must be between 1 and 3600, validated at host startup — a bad value is a clear boot failure rather than readiness silently stuck Pending, and the ceiling catches the transposed digit that would otherwise hold readiness at 503 for weeks in silence.

Both timeouts work by cancelling the token passed to the phase, so they bound only work that observes cancellation. A phase that blocks without checking its token cannot be interrupted by any timeout here and will hold readiness at Pending until it returns — plumb the token through to whatever the phase actually calls.

Enabled: false is a genuine kill switch: warmup completes immediately, and the rest of this configuration is not validated, so a bad timeout cannot block startup on a subsystem that is switched off.

How it plugs in

AddWarmup registers a hosted service that runs the phases, and a health check tagged warmup — the tag MapAltinnHealthChecks() routes onto the readiness endpoint. It works with any MapHealthChecks setup whose readiness predicate includes the warmup tag.

Target frameworks

net8.0, net9.0, net10.0.

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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
0.3.0 91 8/23/2026
0.2.0 100 8/18/2026
0.1.0 105 8/17/2026