Search code examples
.net-corekubernetes-health-check

How do I implement .NET Core Health Checks on a Hosted Service?


The question is just as asked on the title. It is simple to perform a check for the database operations, queries, commands and event store but I am clueless as to how/what is the best way to perform a health check on a hostedservice. Could anyone advice?


Solution

  • Additionally from Simon B, this official Microsoft documentation has drafted out a complete guide to writing a health check structure for your Hosted services.

    You need 3 elements:

    1. The HealthCheck class for your hosted service
    2. The HealthCheck Provider DI, along with the HealthCheck class' DI.
    3. A HealthCheck publisher