.NET implementation of the APIs available at Healthchecks.io
dotnet add package NHealthCheck
Search for NHealthCheck
in your package manager of choice.
This package is built with dependency injection in mind. It's recommended to register it first (Native):
builder.Services.AddHttpClient<IHealthCheckService, HealthCheckService>();
or (Autofac):
var services = new ServiceCollection();
services.AddHttpClient<IHealthCheckService, HealthCheckService>();
builder.Populate(services);
The simplest use is to call the success method when your job finishes:
public class MyJob
{
private IHeathCheckService HealthCheckService { get; }
public MyJob(IHealthCheckService healthCheckService)
{
HealthCheckService = healthCheckService;
}
public Task DoWork()
{
...
await HealthCheckService.SuccessAsync(new Guid(config.HealthCheckGuid));
}
}