Autoheal and healthchecks for APIs and Webjobs on AppService

Chirag Jasuja 0 Reputation points
2023-07-30T06:37:15.39+00:00

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
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,900 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bukke SanthiSwaroop Naik 385 Reputation points
    2023-07-30T08:55:22.7966667+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:

    1. 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.).

    1. 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).
    1. 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

    0 comments No comments