I am seeing 502 errors reported in Diagnose and Solve for my Azure App Service

Michelle Blum 811 Reputation points Microsoft Employee

Within the Web App Down page in Diagnose and Solve for my Azure App Service I am seeing a series of 502 errors that have been occurring consistently for the past few hours. My site is unreachable upon browsing. I have tried restarting the app, and this has not helped. There have been no recent code deployments or configuration changes that led to this error.

Looking at the Microsoft Documentation I see: https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-troubleshooting-502#cause-1

This seems to be an issue with the connectivity to the back end address pool that is behind a gateway which should be managed by Azure.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,155 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach-MSFT 15,531 Reputation points Microsoft Employee

    As you said, 502s generally indicate being unable to connect to back-end instances. A solution to this can be to scale up or scale down your app service plan ensuring that you remain within the same tier (i.e. standard vs premium), so as to not change your inbound virtual IP, wait ~5 minutes, and then scale back.

    Examples: S1 -> S2 or P2v2 -> P1v2

    This operation, also referred to as the "scaling trick", allocates both new instances to the app service plan hosting your web apps, as well as a new internal load balancer. In the event that there is a process hang-up caused by another resource running on the same hardware hosting your instance(s) and your site, this is the most efficient way to move your site to a new instance. Essentially, this functions as a hard reset beyond the capabilities of the traditional restart.

    Lastly, because Azure bills by the hour and this temporary scale is for only 5 minutes, in the event that you need to scale up to remain in the same app service plan tier (i.e. standard vs premium), you will face either negligible cost or no cost at all.

    For future reference, in order to prevent this issue from re-occurring, if you have multiple instances running for your app then please consider enabling health check feature: https://learn.microsoft.com/en-us/azure/azure-monitor/platform/autoscale-get-started#route-traffic-to-healthy-instances-app-service

    You can find other best practices here: https://azure.github.io/AppService/2020/05/15/Robust-Apps-for-the-cloud.html

    Credit to Michelle Blum

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful