.NET Architecture & System Design Interview Question #145

How are health checks configured in ASP.NET Core?

Resilience, Rate Limiting, Health Checks & Observability Senior Advanced

Quick Interview Answer

ASP.NET Core provides health-check services and middleware. Applications can register checks for relevant components and expose endpoints used by infrastructure.

Detailed Explanation

ASP.NET Core provides health-check services and middleware. Applications can register checks for relevant components and expose endpoints used by infrastructure.

Checks can be tagged so different endpoints represent liveness and readiness. Avoid treating every optional dependency as a reason to declare the entire application dead.

Code Example

builder.Services.AddHealthChecks()
    .AddSqlServer(connectionString);

app.MapHealthChecks("/health/ready");
app.MapHealthChecks("/health/live");