One day suddenly on azure app I started to get the error 502 web server received an invalid response while acting as a gateway or proxy server on azure web app.
I did too much research to solve this problem, than I contacted to the support and they given me following solution which works for me.
“Scale up the application to Medium in order to change the instance where your application is running. Wait some minutes and check again your site The above change will change the worker instance.”
I hope this will help to solve the problem