Solution:- There is a 230 second (i.e. a little less than 4 mins) timeout for requests that are not sending any data back. After that, the client gets the 500 you saw, even though in reality the request is allowed to continue server side. You could look at async methods to run additional reports. WebJobs or Azure Functions is another option. Or you could scale up the app service to higher tier and try to complete the process before 230 seconds.
The 4 minute idle timeout on the TCP level and this is implemented on the Azure hardware load balancer. This timeout is not configurable and this cannot be changed. One thing I want to mention is that this is idle timeout at the TCP level which means that if the connection is idle only and no data transfer happening, only then this timeout is hit. To provide more info, this will hit if the web application got the request and kept processing the request for > 4minutes without sending any data back.
A common practice to keep the connection active for a longer period is to use TCP Keep-alive. Packets are sent when no activity is detected on the connection. By keeping on-going network activity, the idle timeout value is never hit and the connection is maintained for a long period
Ideally, in a web application, it is not good to keep the underlying HTTP request open and 4 minutes is a decent amount of time. If you have a requirement about background processing within your web application, then the recommended solution is to use Azure WebJobs/Function App and have it nteract with the Azure Webjob to notify once the background processing is done (there are many ways that Azure provides like queues triggers etc. and you can choose the method that suits you the best). Azure Webjobs/Functions are designed for background processing and you can do as much background processing as you want within them. Source
Alternative Titles: Timeout after 4 minute long server call in azure webapp
Make Web App Timeout of 230 seconds configurable
Increase azure web app request timeout
Azure 4 min timeout in web app
Azure App Service outbound request timeout
Azure Webapp Request returning 502 after 4 min
Azure Web Apps Timeout long process request
Allow a request timeout of more then 3.8 minutes
Azure app has request timeout of 4 minutes. This is not suitable for bigger operation, can it be handled through Azure Functions ??