Adam
Adam

Reputation: 21

AspNetCore Health Checks UI could not get endpoint URI from configuration

I'm trying to implement the AspNetCore.HealthChecks.UI Nuget package and it's working locally on my PC, but when I host it on IIS I'm getting the following error:

error1

This is the configuration in my appsettings.json file:

{
  "HealthChecks-UI": {
    "HealthChecks": [
      {
        "Name": "MySiteName",
        "Uri": "/healthchecks"
      }
    ]
  }
}

I know it can read the endpoint URI from here because if I set it to http://localhost:8888/healthchecks then the error changes to:

enter image description here

I can access the /healthchecks page directly in the browser and view the JSON output.

In my Program.cs I have:

builder.Services.AddHealthChecks()
    .AddCheck<MyCustomHealthCheck1>("Health check 1")
    .AddCheck<MyCustomHealthCheck2>("Health check 2")
    .AddCheck<MyCustomHealthCheck3>("Health check 3");

builder.Services.AddHealthChecksUI().AddInMemoryStorage(); 
app.MapHealthChecks("/healthchecks", new HealthCheckOptions
{
    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});

app.MapHealthChecksUI();

I want to use a relative URI if possible so that users of my web application do not have to configure it in the appsettings.json file. Part of the reason I'm implementing healthchecks UI is to check for configuration errors on our client sites, so requiring it's own configuration is counter intuitive.

Upvotes: 0

Views: 687

Answers (0)

Related Questions