A comprehensive guide to implementing health checks in ASP.NET Core on .NET 10, covering the full spectrum from basic setup to production-grade patterns. Key topics include: returning structured JSON responses, adding database (EF Core, PostgreSQL) and Redis checks, writing custom IHealthCheck implementations with the Degraded state, and the critical liveness vs. readiness vs. startup probe split. The guide explains how putting a database check in a liveness probe can trigger cascading restart loops across all replicas. It also covers graceful traffic draining before pod shutdown using AddApplicationLifecycleHealthCheck and a preStop sleep hook, probe cost arithmetic (up to 138,000 dependency round trips per day at idle), and mitigation via ShortCircuit, output caching, and IHealthCheckPublisher. A notable finding: the Health Checks UI 9.0.0 package pulls in a KubernetesClient version with a moderate CVE, and its EF Core 8 InMemory storage provider crashes at runtime when used with EF Core 10 unless explicitly pinned.
Table of contents
What are health checks in ASP.NET Core?PrerequisitesHow do you add a basic health check?Middleware in ASP.NET CoreHow do you return a detailed JSON health response?Global Exception Handling in ASP.NET CoreHow do you add a database health check in EF Core?Building a CRUD API with EF CoreHow do you add a Redis health check?Distributed Caching in ASP.NET Core with RedisHow do you check an external URL or downstream service?How do you write a custom health check?Liveness vs readiness vs startup probes: which check goes where?How do you add a Health Checks UI dashboard?Structured Logging with SerilogHow do you wire health checks into Kubernetes?Docker Guide for .NET DevelopersHow do you drain traffic before a pod shuts down?What do your health checks actually cost?Securing and tuning the endpointsEnvironment-Based Configuration in ASP.NET CoreKey takeawaysIHostedService vs BackgroundServiceFAQTroubleshootingContainerize .NET Without a DockerfileSummaryBest Libraries for ASP.NET Core23.6K Impressions1 Comment
1 Award