The Health Check feature allows you to specify a path on your application for App Service to ping. If an instance fails to respond to the ping, the system determines it is unhealthy and removes it from the load balancer rotation. This increases your application’s average availability and resiliency.
When the instance is unhealthy and removed from the load balancer, the service continues to ping it. If it begins responding with successful response codes, then the instance is returned to the load balancer. If it continues to respond unsuccessfully, App Service will restart the underlying VM in an effort to return the instance to a healthy state.
Health Check integrates with App Service’s authentication and authorization features, so the system will reach the endpoint even if these security features are enabled. If you are using your own authentication system, the health check path must allow anonymous access.
The health check path should check the critical components of your application. For example, if your application depends on a database and a messaging system, the health check endpoint should connect to those components. If the application cannot connect to a critical component, then the path should return a HTTP error response code to indicate that the app is unhealthy.
How to setup the Health Check path in the Azure Portal
- Go to the Azure Portal
- Go to the App Service
- Then go to the Monitoring Section from the left menu.
- Health Check
- Add the Health Check Path
- Click on save.
Note: Saving the changes will generate a restart of the application.
If you want to make sure that your health check path was added successfully, please use the following URL: https://resources.azure.com/ to check that you added the path correctly in your web application. You will need to follow the next steps:
- Expand your subscription.
- Go to Resource Groups.
- Select the Resource Group where the app service is hosted.
- The select providers.
- Then select Microsoft Web.
- Open sites
- And open your app service.
- Then open config.
- And lastly web.
- You will need to scroll to the bottom to find the variable called ‘healthCheckPath’ and you will see the value there for the path you set in the portal.
How to see and analyze Health Check metrics from the Azure Portal
- Go to Health Check.
Once you are in the metrics section, you will be able to see the Health Check status of your application:
You can also select the option ‘Apply Splitting’ by instance to see the Health Check status in each of your App Service Plan instances: