Health Checks
Configure Health Checks
// Web Application Builder code goes here
builder.Services.AddHealthChecks()
.AddCheck<BrighterServiceActivatorHealthCheck>("Brighter", HealthStatus.Unhealthy);
var app = builder.Build();
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/health");
endpoints.MapHealthChecks("/health/detail", new HealthCheckOptions
{
ResponseWriter = async (context, report) =>
{
var content = new
{
Status = report.Status.ToString(),
Results = report.Entries.ToDictionary(e => e.Key,
e => new
{
Status = e.Value.Status.ToString(),
Description = e.Value.Description,
Duration = e.Value.Duration
}),
TotalDuration = report.TotalDuration
};
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonSerializer.Serialize(content, JsonSerialisationOptions.Options));
}
});
});
app.Run();
Health Status
Scenario
Status
Last updated
Was this helpful?
