Azure ASP .net WebApp The request timed out
<p>I have deployed an ASP .net MVC web app to Azure App service. </p>

<p>I do a GET request from my site to some controller method which gets data from DB(DbContext). Sometimes the process of getting data from DB may take more than 4 minutes. That means that my request has no action more than 4 minutes. After that Azure kills the connection - I get message:</p>

<blockquote>
  <p><h2>500 - The request timed out.</h2>   The web server failed
  to respond within the specified time.</p>
</blockquote>

<p>This is a method example: </p>

<pre><code> [HttpGet]
    public async Task&lt;JsonResult&gt; LongGet(string testString)
    {            
       var task = Task.Delay(360000);
        await task;            
        return Json("Woke", JsonRequestBehavior.AllowGet);
    }
</code></pre>

<p>I have seen a lot of questions like this, but I got no answer:</p>

<p><a href="https://social.msdn.microsoft.com/Forums/azure/en-US/560dc2a9-43e1-4c68-830c-6e1defe2f72d/azure-web-app-request-timeout-issue?forum=" rel="noreferrer">Not working 1</a>
Cant give other link - reputation is too low. </p>

<p>I have read this <a href="https://azure.microsoft.com/ru-ru/blog/new-configurable-idle-timeout-for-azure-load-balancer/" rel="noreferrer">article</a> - its about Azure Load Balancer  which is not available for webapps, but its written that common way of handling my problem in Azure webapp is using TCP Keep-alive. So I changed my method:  </p>

<pre><code>[HttpGet]
    public async Task&lt;JsonResult&gt; LongPost(string testString)
    {
        ServicePointManager.SetTcpKeepAlive(true, 1000, 5000);
        ServicePointManager.MaxServicePointIdleTime = 400000;
        ServicePointManager.FindServicePoint(Request.Url).MaxIdleTime = 4000000;
       var task = Task.Delay(360000);
        await task;            
        return Json("Woke", JsonRequestBehavior.AllowGet);
    }
</code></pre>

<p>But still get same error. 
I am using simple GET request like </p>

<pre><code>GET /Home/LongPost?testString="abc" HTTP/1.1
Host: longgetrequest.azurewebsites.net
Cache-Control: no-cache
Postman-Token: bde0d996-8cf3-2b3f-20cd-d704016b29c6
</code></pre>

<p>So I am looking for the answer what am I doing wrong and how to increase request timeout time in Azure Web app. Any help is appreciated. </p>

<p>Azure setting on portal: </p>

<p>Web sockets - On</p>

<p>Always On - On</p>

<p>App settings: </p>

<p>SCM_COMMAND_IDLE_TIMEOUT = 3600</p>

<p>WEBSITE_NODE_DEFAULT_VERSION = 4.2.3</p>