title: Azure - WebJob timeout when calling stored procedure
body: <p>I have a webjob that calls a long running stored procedure that keeps timing out. Can anyone help please? </p>
  
  <p>The web job is called using the following code:</p>
  
  <pre><code>    static void Main()
      {
          ApplicationDbContext context = new ApplicationDbContext();
  
          context.Database.CommandTimeout = 6000;
  
          context.PopulateJobTypeDescendants();
  
      }
  </code></pre>
  
  <p>The method on the context (ApplicationDbContext) is shown below:</p>
  
  <pre><code>    public void PopulateJobTypeDescendants()
      {
          Database.ExecuteSqlCommand("PopulateJobTypeDescendants");
      }
  </code></pre>
  
  <p>The following exception is raised when the web job is run. We have read that it could be related to the plan/DTUs on the server so we went from S1 -> S3, this still didn't solve the issue and the process bombs out after 45 seconds. The strange thing is that if I connect to azure sql db from SSMS and call the stored procedure it works fine.</p>
  
  <blockquote>
    <p>[07/11/2016 22:25:02 > e2cf50: ERR ] Unhandled Exception:
    System.Data.SqlClient.SqlException: Timeout expired.  The timeout
    period elapsed prior to completion of the operation or the server is
    not responding.  This failure occurred while attempting to connect to
    the routing destination. The duration spent while attempting to
    connect to the original server was - [Pre-Login] initialization=14;
    handshake=26; [Login] initialization=0; authentication=0; [Post-Login]
    complete=1;   ---> System.ComponentModel.Win32Exception: The wait
    operation timed out</p>
  </blockquote>
  
  <p>The connection string is shown below:</p>
  
  <pre><code>&lt;add name="TempsContext" connectionString="Server=tcp:[XXX],1433;Database=temps_testing;User ID=[XXX];Password=[XXX];Trusted_Connection=False;Encrypt=True;Connection Timeout=600;" providerName="System.Data.SqlClient" /&gt;
  </code></pre>