Health Checks
AspNet Zero has an implementation of health checks and health checks UI.
You can enable or disable health checks and health checks UI.
Settings
Health checks settings are located in the appsettings.json
file
Note: If you enable Health Checks UI, don't forget to change your
health
URL before you publish your website.
Adding new health check
There are a lot of libraries which you can add to your health check easily. To see a full list of libraries and used package in AspNet Zero, see https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks. Here are some sample package names:
AspNetCore.HealthChecks.System
AspNetCore.HealthChecks.Network
AspNetCore.HealthChecks.SqlServer
...
Adding your custom health check
To add your own health check, you should create a class inherited from IHealthCheck
. ( Already implemented health check classes are located under HealthChecks folder of .Application
project.)
In both cases, you should add your health checks to HealthCheckBuilder. HealthCheckBuilder is located in .Web.Core
project. ( .Web.Core -> HealthCheck -> AbpZeroHealthCheck.cs -> AddAbpZeroHealthCheck )
.
After adding your new health check here, you will be able to see its status in JSON and UI automatically.
Endpoints:
MVC project (Only exists in ASP.NET Core & jQuery version)
Health checks UI endpoint: https://localhost:44302/healthchecks-ui (if it is enabled)
Health checks JSON result endpoint: https://localhost:44302/health (if it is enabled)
Host project (Available in ASP.NET Core versions but designed for Angular project)
Health checks UI endpoint: https://localhost:44301/healthchecks-ui (if it is enabled)
Health checks JSON result endpoint: https://localhost:44301/health (if it is enabled)
Public Website
Health checks UI endpoint: http://localhost:45776/healthchecks-ui (if it is enabled)
Health checks JSON result endpoint: http://localhost:45776/health (if it is enabled)
see also:
https://github.com/xabaril/AspNetCore.Diagnostics.HealthChecks
https://docs.docker.com/engine/reference/builder/#healthcheck
Note: If you enable health checks, it will create its dbContext. That's why, when you try to create new migration or update database you should also use
-c [YourProjectName]DbContext
command.