Azure Frontdoor defaults
Backend Default Timeout : 30 Seconds
Max Backend Timeout : 4 Minutes
Your backend is taking longer than the timeout configured (default is 30 seconds)to receive the request from Azure Front Door
If going through Azure Front Door results in a 503 error response code, configure the sendReceiveTimeout field for Azure Front Door. You can extend the default timeout up to 4 minutes (240 seconds). The setting is under backendPoolSettings and is called sendRecvTimeoutSeconds.
Azure Application Gateway
Pay attention to health probe timeouts. Default health probe timeout is 30 seconds. If you application takes more than 30 seconds to respond then it wold be considered unhealthy. You may want to increase that timeout.
Pay attention to request timeouts. Default request timeouts are 30 seconds and that may be too short for some applications. If gateway is not receiving response from backend in 30 seconds then it would abort the HTTP request is return error 502 (bad gateway) to the caller. Request timeouts are configured in AAG Http Settings.