From the course: ASP.NET Core: Health Checks and Logging

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Adding database health checks

Adding database health checks - ASP.NET Core Tutorial

From the course: ASP.NET Core: Health Checks and Logging

Start my 1-month free trial

Adding database health checks

- [Instructor] So our web application depends on the API and the API depends on the database. So how about we shut down the database? I stop it. And then after it has been shut down, I can add a health check, which gives me that information. Now, truth to be told, problem more or less is that I've put all the database information in the API, so I could now add a health check feature to the API. And the API would then query the status of the database but to make things a little bit more simple, I just queried the status of the database directly from the web project. But the mechanisms I think are obvious. So you could also refactor this so that the API has this health check and exposes this information. How do we do this? Well, of course, we have our AddHealthChecks method and within that method, we can do AddCheck and then for instance, reference DbHealthCheck. A DbHealthCheck is a class we need to implement.…

Contents