Getting 502 Bad Gateway with Azure App Gateway with Web App as Backend

Pallab Chakraborty 401 Reputation points
2022-07-04T01:45:28.557+00:00

I am getting "502 Bad Gateway" after provisioning my Azure App Gateway. Let me explain the configuration for my infrastructure. We operate in a Landing Zone Environment where the spokes are routing traffic via the Hub
We have an Azure Firewall in the hub. We have multiple projects which are like individual landing zones sitting in individual subscriptions.

I have a similar setup in another landing zone where i have three backends : A Front End vue.js app, an API app and a Function App , all operating in one app service plan. All the Apps are VNET integrated and Private Endpoint enabled. I have created a route table with next hop as internet and attached it to the WAF subnet
I also have created three custom domains for the three apps and used well known CA certs and created TXT records and A records for them in our DNS server
So when i try to browse the friendly URL , it hits the App Gateway and i am able to browse the front end site absolutely fine.

But in this particular project, i have 5 web apps - One UI app and 4 API apps.
I have one app registration which is acting as the identity provider for the app. I have created similar kind of Route Table as i did for the other project and attached it to the WAF subnet. Here also, my apps are VNET integrated and Private Endpoint enabled
Right now , the code for my app is not deployed and it is an empty app service

So ideally , i should be getting the Microsoft page which says that your web app is running fine when i browse the UI app with its friendly URL
But instead i am getting 502 bad gateway.

So what can be the issue here ? I tried tunneling to the remote hub and tried accessing the UI app with its friendly URL bypassing the App Gateway, but still then i get 502 bad gateway. When i look at the overview page of the App Gateway via the Azure portal, it complains that the backend health is not right in a red banner

So i am not understanding what is the issue here, i have deleted and recreated the App Gateway, still the same.

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
230 questions
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,063 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,758 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.