Search code examples
azureazure-web-app-servicegithub-actionswebhookscicd

Ensuring Application Health: How to Check Azure App Service Health Post-Deployment


I deployed my application to Azure App Service and I want to ensure its health after the deployment. How can I check the health of my Azure App Service application programmatically or through automated processes? Specifically, I'm interested in post-deployment health checks to verify that the new version is functioning correctly. If the health check failed would want to rollback to previous version along with sending notification in MS Teams/email.

I tried a way where I waited for the deployment to succeed by pausing execution (Sleeping in Github actions for 6 minutes) because the deployment takes around 6 minutes. Afterward, I made an HTTPS call to the health endpoint. If the response indicated failure, I sent a notification and performed a rollback. Otherwise, no further action was necessary. However, using this approach in GitHub Actions would lead to increased costs since the waiting time of 6 minutes is billable.

Are there any specific way in Azure like Webhook/APIs, or techniques that can help me accomplish this? Any guidance or code examples would be greatly appreciated.

Note: I want to accomplish this using Azure App Service Only (No plan of using Azure Kubernetes Service)


Solution

  • We have various options to check the health status of Azure App service.

    Azure Monitoring: enter image description here

    Health Check:

    enter image description here

    • Enable the Health check option and save.

    enter image description here

    • Click on the Metrics

    enter image description here

    • Click on Add metric => select the metric Health check status .

    enter image description here

    Refer this MSDoc on how to How to Monitor App Service instances using Health check for more details.

    how can I rollback to previous version if the app is unhealthy

    To roll back the app to the previous version we can use deployment slots.

    • Create two different slots and make request with one slot.
    • If it fails and you face any issue we can swap the failed slot with the existing one(2nd slot).