Hello @kashif Javed ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I would advise you to check the Details column on the Backend Health tab of your Application gateway and see if you are receiving any of the error messages listed in the below article and follow the recommended solution:
https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-backend-health-troubleshooting
You can also follow the below troubleshooter for 502 errors in Application gateway:
https://support.microsoft.com/en-us/topic/troubleshooter-bad-gateway-502-errors-in-azure-application-gateway-15736e04-810c-24ca-53e3-0b95e653c168
Kindly let us know if the above helps or you need further assistance on this issue.
----------------------------------------------------------------------------------------------------------------
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.