The health check API in ASP.NET Core 5
ASP.NET Core 5 has a built-in middleware (available via the Microsoft.Extensions.Diagnostics.HealthChecks
NuGet package) to report the health status of the application components exposed as an HTTP endpoint. This middleware makes it so easy to integrate health checks for databases, external systems, and other dependencies. It is also extensible, so we can create our own custom health checks.
In the next section, we will add a health check endpoint to our Ecommerce portal.
Adding a health check endpoint
In this section, we will add a health check endpoint to our Packt.Ecommerce.Web
application:
- In order to add a health check endpoint, we need to first add the
Microsoft.Extensions.Diagnostics.HealthChecks
NuGet package reference to thePackt.Ecommerce.Web
project, as shown in the following screenshot: - Now we need to register the
HealthCheckService...