Skip to main content

Command Palette

Search for a command to run...

Implementing Health Checks in ASP.NET Core

Published
1 min read

Here is a nice article on Implementing Health Checks in ASP.NET Core.

Gist

public void ConfigureServices(IServiceCollection services)
{
    services.AddHealthChecks()
        .AddDbContextCheck<WeatherForecastDbContext>();
    services.AddControllers();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    //Code omitted for brevity
    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
        endpoints.MapHealthChecks("/health");
    });
}
Implementing Health Checks in ASP.NET Core