I have gone through your question related to Azure and I know how to fix the issue.
These 502 errors are not visible in the IIS logs as they are always thrown by your front end server which are basically try to forward your requests to a worker who is hosting your site and you can find many reasons why your front end is returning 502 error.
I had setup with my web servers behind the azure application gateway out of them some servers were working properly but traffic to one of those server was having a 502 issue. So I just followed below approach:
I simply checked my Backend health on my application gateway and I found that one of the server couldn’t be reached.So I tried to open a backend server url on my cloud VM a root of my website can't be reached. But my App was running. It turned out a gateway was supposed to ping a port 80 of a target machine and then I just disabled a root website on a target server. So my gateway assumed my server is dead and just refused to do a redirect.