title: Using Async/Await with Azure App Services Web API
body: <p>I have a .Net Web Api hosted as Azure App Service. (I have to call this from ADF as a web activity.)</p>
  
  <p>This API has some code which runs for a long time so <a href="https://stackoverflow.com/questions/44820256/how-can-increase-azure-app-service-230-sec-request-time-out">I want to make this Async</a>. </p>
  
  <p>This is how I am testing:</p>
  
  <pre><code>[Route("apiA/[controller]")]
      [ApiController]
      public class AsynccallController : ControllerBase
      {
  
          [HttpPost]
          public async Task&lt;String&gt; PostA()
          {
              var strTask = await Longfunction();
              return strTask;
          }
  
          private Task&lt;string&gt; Longfunction()
          {
              Thread.Sleep(TimeSpan.FromSeconds(300));
              return Task.FromResult("value1");
          }
  
      }
  </code></pre>
  
  <p>And testing from postman: 
  <a href="https://i.stack.imgur.com/5zfyD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5zfyD.png" alt="enter image description here"></a></p>
  
  <p>According <a href="https://docs.microsoft.com/en-us/dotnet/csharp/async#basic-overview-of-the-asynchronous-model" rel="nofollow noreferrer">to this documentation</a>, the await keyword should return the control to the caller function (in this case postman) before it executes the sleep. But I do not see that happening. It still waits for those 300 seconds to send response to postman, which is like a sync call. why?</p>
  
  <p>And secondly if it does send control back at 'await', then when and how does the return statement send the value back?</p>
  
  <p>Thanks.</p>