Health Checks

The IEvangelist.Azure.CosmosRepository.AspNetCore package adds support for AspNet Core Health Checks using the HealthChecks.CosmosDb package.

Setup

To configure Cosmos DB health checks:

services.AddHealthChecks().AddCosmosRepository();

By default, this will scan all of the assemblies in your solution to locate the container names for each of your IItem types. To refine this, and potentially reduce startup times, pass in the Assemblies containing your IItem types:

services.AddHealthChecks().AddCosmosRepository(assemblies: typeof(ExampleItem).Assembly);

The Cosmos Repository Health package supports all of the existing functionality of Health Checks, such as failureStatus and tags, see the Microsoft Documentation for configuration details.

Don’t forget to map the health endpoint with:

app.MapHealthChecks("/healthz");