Health checks in ASP.NET Core

Viewed 243

I am trying to make a 'optional' healthcheck; and endpoint that can be used in the UI to determine if a feature is visible or not.

So in ConfigureServices I'm adding it this way:

.AddUrlGroup(new Uri(searchEngineConfig.Get<SearchEngineConfiguration>().Endpoint + SwaggerEndPoint), "Search API", failureStatus: HealthStatus.Degraded, tags: new string[] { "Optional", "Search" })

in Configure I have this

app.UseHealthChecks(HealthReadyEndPoint, new HealthCheckOptions()
    {
        Predicate = (check) => !check.Tags.Contains("Optional")
    });
app.UseHealthChecks(HealthLiveEndPoint, new HealthCheckOptions()
    {
        Predicate = (check) => false,
    });
app.UseHealthChecks(HealthSearchEndPoint, new HealthCheckOptions()
    {
        Predicate = (check) => check.Tags.Contains("Search")
    });

Basically, it works great; only when the search engine isn't available on startup the ASP.NET Core app doesn't seem to start at all and keeps throwing "connection refused" errors.

0 Answers
Related