Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
Autoheal and healthchecks for APIs and Webjobs on AppService
I have an API and Webjob hosted on a same AppService. I want to implement healthchecks and autoheal features to improve platform stability.
Can you help me on how I can implement these features for both API and Webjobs.
Azure App Service
Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
-
Bukke SanthiSwaroop Naik • 395 Reputation points
2023-07-30T08:55:03.89+00:00 Implementing health checks and auto-healing for your API and WebJobs on the same Azure App Service can significantly improve platform stability and ensure that your services are available and responsive. Below, I'll provide an overview of how to achieve this for both your API and WebJobs:
- Health Checks for API: Health checks allow you to monitor the health of your API and determine if it's running correctly. Azure App Service provides built-in health checks that you can enable for your API. Here's how to set it up:
- In your API project, add a route or endpoint specifically for health checks (e.g.,
/health). - Implement the logic to check the health of your API services and return an appropriate status code (e.g., 200 for healthy, 500 for unhealthy).
- Deploy your updated API to the Azure App Service.
Azure App Service automatically detects the health check endpoint and starts monitoring it. If the health check endpoint returns a non-200 status code, the App Service will mark your API as unhealthy and take appropriate action based on your auto-heal settings (e.g., recycle the app, send an alert, etc.).
- Health Checks for WebJobs: Azure App Service does not provide built-in health checks for WebJobs like it does for APIs. However, you can implement custom health checks for your WebJobs by following a similar approach to the API health checks:
- Within your WebJobs, create a specific endpoint or trigger a function for health checks (e.g.,
/health). - Implement the logic to check the health of your WebJobs, such as checking if critical processes are running or resources are available.
- Ensure the health check endpoint returns appropriate status codes (e.g., 200 for healthy, 500 for unhealthy).
- Auto-Healing: To enable auto-healing, follow these steps:
- Go to the Azure portal and navigate to your App Service.
- In the left navigation pane, select "Diagnose and solve problems."
- Under "Availability and performance," select "Auto Heal."
- In the "Auto Heal" pane, enable "Custom" and configure the trigger based on your requirements (e.g., based on response time, HTTP status code, or request rate).
- Choose the appropriate action to take when the trigger condition is met (e.g., recycle the app, send an email, etc.).
By configuring auto-healing based on specific health check criteria, Azure App Service can automatically take corrective action when an issue is detected, improving the stability and responsiveness of your services.
If you still have questions, please let us know in the "comments" and we would be happy to help you. Commenting is the fastest way of notifying the experts.
If the answer has been helpful, we appreciate hearing from you and would love to help others who may have the same question. Accepting answers helps increase the visibility of this question for other members of the Microsoft Q&A community.
Thank you for helping to improve Microsoft Q&A! User's image
-
Deleted
This comment has been deleted due to a violation of our Code of Conduct. The comment was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
-
Chirag Jasuja • 0 Reputation points
2023-07-30T09:37:51.74+00:00 Thanks a lot for your answer.
A followup question is. I have read in some places that autoheal ony works for web portion of app service (here API).
How can I autoheal the webjob side?
-
Chirag Jasuja • 0 Reputation points
2023-08-01T07:45:40.4833333+00:00 Thanks for your answer.Does autoheal work for webjobs as well?.I have a continuous webjob.
-
SnehaAgrawal-MSFT • 22,721 Reputation points • Moderator
2023-08-02T17:03:28.1366667+00:00 @Chirag Jasuja Auto-heal is a feature that allows your App Service to automatically recover from certain types of failures, such as crashes or high CPU usage.
You can configure auto-heal for both your API and WebJobs using the same approach.
Note that for continuous WebJobs, auto-heal will not be able to recover from issues that cause the WebJob to stop processing.
In this case, you may need to manually restart the WebJob or investigate the issue further to determine the root cause.
However, auto-heal can still be useful for detecting and recovering from other types of issues, such as high CPU usage or memory leaks.
-
Angel Bareño Leon • 20 Reputation points
2025-01-16T22:27:51.8266667+00:00 Hi, can you help me with this question, if I enable or disable auto heal on an app service with a webapp, while I do that the app service have a downtime or it works normally?
-
Wilma Galliher • 0 Reputation points2026-08-24T10:55:16.9333333+00:00 For a continuous WebJob, App Service Auto-Heal mainly acts on the App Service process itself. It may recycle the App Service when configured triggers occur, but it does not directly monitor whether the WebJob is actively processing work. For reliable WebJob monitoring, use Application Insights/monitoring to detect failures or inactivity and use an external mechanism such as Azure Automation or Azure Functions to restart the WebJob when necessary.