ServiceDefaults.HealthChecks 1.3.1

dotnet add package ServiceDefaults.HealthChecks --version 1.3.1
                    
NuGet\Install-Package ServiceDefaults.HealthChecks -Version 1.3.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="ServiceDefaults.HealthChecks" Version="1.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ServiceDefaults.HealthChecks" Version="1.3.1" />
                    
Directory.Packages.props
<PackageReference Include="ServiceDefaults.HealthChecks" />
                    
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 ServiceDefaults.HealthChecks --version 1.3.1
                    
#r "nuget: ServiceDefaults.HealthChecks, 1.3.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.
#:package ServiceDefaults.HealthChecks@1.3.1
                    
#: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=ServiceDefaults.HealthChecks&version=1.3.1
                    
Install as a Cake Addin
#tool nuget:?package=ServiceDefaults.HealthChecks&version=1.3.1
                    
Install as a Cake Tool

ServiceDefaults.HealthChecks

Production-ready health check infrastructure for ASP.NET Core services with separate liveness, readiness, and startup endpoints - designed for Kubernetes deployments.

Installation

dotnet add package ServiceDefaults.HealthChecks

Quick Start

var builder = WebApplication.CreateBuilder(args);

// Add health check infrastructure
builder.AddHealthCheckDefaults();

// Add PostgreSQL readiness check
builder.AddPostgresReadinessCheck(
    builder.Configuration.GetConnectionString("Postgres")!);

var app = builder.Build();

// Run migrations BEFORE marking ready
using (var scope = app.Services.CreateScope())
{
    var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
    await db.Database.MigrateAsync();
}

// Mark app as ready AFTER migrations complete
app.MarkAsReady();

// Map health endpoints
app.MapHealthCheckEndpoints();

app.Run();

Health Check Endpoints

Endpoint Purpose Checks Kubernetes Probe
/health/live Is the app running? Self check only livenessProbe
/health/start Has startup finished? Startup state only startupProbe
/health/ready Can it handle traffic? DB + Startup state readinessProbe

Why Separate Endpoints?

Probe Checks Fails when Effect
Liveness App loop only App is wedged Container restarted
Readiness DB + migrations Traffic would fail Removed from LB

Critical Rule: Liveness should NEVER check external dependencies like databases. A database hiccup shouldn't restart your containers.

Kubernetes Configuration

livenessProbe:
  httpGet:
    path: /health/live
    port: 8080
  periodSeconds: 10
  timeoutSeconds: 1
  failureThreshold: 3

readinessProbe:
  httpGet:
    path: /health/ready
    port: 8080
  periodSeconds: 5
  timeoutSeconds: 2
  failureThreshold: 1

startupProbe:
  httpGet:
    path: /health/start
    port: 8080
  failureThreshold: 30
  periodSeconds: 5

API Reference

Builder Extensions

// Add core health checks (liveness + startup state)
builder.AddHealthCheckDefaults();

// Add PostgreSQL readiness check
builder.AddPostgresReadinessCheck(connectionString, name: "postgres", timeout: TimeSpan.FromSeconds(2));

App Extensions

// Map endpoints (defaults: /health/live, /health/ready)
app.MapHealthCheckEndpoints();

// Custom paths
app.MapHealthCheckEndpoints(
    liveEndpoint: "/healthz",
    readyEndpoint: "/ready");

// Mark ready after initialization
app.MarkAsReady();

// Get startup state for manual control
var state = app.GetStartupState();
state.MarkReady();
state.MarkNotReady(); // For graceful shutdown

StartupState

The StartupState class tracks whether your app has completed initialization:

// Injected via DI
public class MyService
{
    private readonly StartupState _startupState;

    public MyService(StartupState startupState)
    {
        _startupState = startupState;
    }

    public bool IsReady => _startupState.IsReady;
}

Response Format

Health endpoints return JSON:

{
  "status": "Healthy",
  "totalDuration": 12.5,
  "checks": [
    {
      "name": "postgres",
      "status": "Healthy",
      "duration": 10.2,
      "description": null,
      "exception": null
    },
    {
      "name": "startup",
      "status": "Healthy",
      "duration": 0.1,
      "description": "Application startup complete",
      "exception": null
    }
  ]
}

License

MIT License

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on ServiceDefaults.HealthChecks:

Package Downloads
Dloizides.ServiceDefaults

Aspire-style service defaults for ASP.NET Core: OpenTelemetry (logging/metrics/tracing) wiring, HTTP resilience + service discovery, standard health-check registration (via ServiceDefaults.HealthChecks), and the platform endpoint map (anonymous /health/live|start|ready Kubernetes probes plus an ACME HTTP-01 no-op). Extracted from ~8 services that had each hand-copied the ServiceDefaults/Extensions.cs; normalizes the PostgressConnection connection-string typo by resolving both the correct (PostgresConnection) and legacy-typo keys.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.1 1,080 3/7/2026
1.3.0 1,283 1/11/2026
1.2.4 134 1/10/2026
1.2.3 134 1/10/2026
1.2.2 126 1/10/2026
1.2.1 135 1/10/2026
1.2.0 140 1/10/2026
1.1.0 128 1/10/2026
1.0.1 125 1/10/2026