Skip to content
bitzorcas
EN

Concept

Health checks

Liveness and readiness health probes — Aspire ServiceDefaults with tagged checks for process health and dependency readiness.

Last updated

BitzOrcas provides two-tier health checks via Aspire ServiceDefaults — liveness for process health and readiness for dependency availability.

Two tiers

Liveness (/health/live)

Proves the process is running and responding. No external dependencies checked.

builder.Services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy("alive"),
tags: [LivenessTag]);

K8s usage: livenessProbe → restart pod if failing.

Readiness (/health/ready)

Checks critical external dependencies. Fails gracefully — won’t restart the process, but signals the load balancer to stop routing traffic.

K8s usage: readinessProbe → remove from service endpoint pool.

Production readiness checks are registered by infrastructure adapters:

DependencyRegistered byCheck
SQL ServerPersistenceAdaptersConnection + query
RabbitMQPersistenceAdaptersConnection
(Future) RedisCaching adapterConnection + ping

Tags

public const string LivenessTag = "live";
public const string ReadinessTag = "ready";

Endpoints

GET /health/live → 200 OK (always, if process is alive)
GET /health/ready → 200 OK (all dependencies healthy) or 503 (dependency down)
GET /health → All registered checks (unfiltered)

Configuration

Health check endpoints are registered by Aspire’s AddServiceDefaults():

// In Program.cs — already included
builder.AddServiceDefaults();
// Map health endpoints
app.MapHealthChecks("/health");
app.MapHealthChecks("/health/live", new HealthCheckOptions
{
Predicate = check => check.Tags.Contains("live")
});
app.MapHealthChecks("/health/ready", new HealthCheckOptions
{
Predicate = check => check.Tags.Contains("ready")
});

Adding custom health checks

Register additional readiness checks in your adapter:

services.AddHealthChecks()
.AddNpgSql(connectionString, name: "postgres", tags: ["ready"]);
services.AddHealthChecks()
.AddRabbitMQ(rabbitMqConnectionString, name: "rabbitmq", tags: ["ready"]);

See also