TILT–HealthCheck–part 8

Read about https://docs.microsoft.com/en-us/azure/architecture/patterns/health-endpoint-monitoring

In ASP.NET Core it is easy to add health checks to your web application.

I have added for Sqlite in the release and for SqlServer in the Azure.

This is the code

bool IsBuildFromCI = new XAboutMySoftware_78102118871091131225395110108769286().IsInCI;
//more code
builder.Services
     .AddHealthChecksUI(setup =>
     {

         var health = "/healthz";
         if (IsBuildFromCI)
         {
             health = builder.Configuration["MySettings:url"] + health;
         }
         setup.AddHealthCheckEndpoint("me",health );
         setup.SetEvaluationTimeInSeconds (60*60);
         //setup.SetHeaderText
         setup.MaximumHistoryEntriesPerEndpoint(10);
     }
        
    )
     .AddInMemoryStorage()
     ;

//more code
app.MapHealthChecks("healthz", new HealthCheckOptions
{
    Predicate = _ => true,
    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.MapHealthChecksUI(setup =>
{

});

You can see the result at

https://tiltwebapp.azurewebsites.net/healthz https://tiltwebapp.azurewebsites.net/healthchecks-api https://tiltwebapp.azurewebsites.net/healthchecks-ui

Also, you can monitor at Monitoring – health check. Also, it would help to see the logs in real time, at Monitoring – logstream

Tools used

AspNetCore.HealthChecks.Sqlite

AspNetCore.HealthChecks.SqlServer

AspNetCore.HealthChecks.UI

AspNetCore.HealthChecks.UI.Client

AspNetCore.HealthChecks.UI.InMemory.Storage

Visual Studio