An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
The confirmed root cause here was the backend request timeout. Application Gateway waits only for the timeout configured in the Backend Setting associated with the route. On v2, when the backend does not respond within that interval, the gateway returns 504; timeout or connectivity failures can also appear as 502 depending on the SKU and failure path.
Increase the request timeout to a value longer than the slowest legitimate backend response, then verify the change has finished provisioning. Also align any upstream web-server or reverse-proxy timeout so it does not expire first.
Use Application Gateway access logs and backend latency metrics to choose the value rather than setting it arbitrarily. If 502 responses continue when requests are not slow, check Backend Health, the probe host/path, DNS/NSG/UDR reachability, and the backend TLS certificate/SNI. Increasing the timeout fixes slow responses; it does not fix an unhealthy or unreachable backend.