title: Azure SQL Timeout
body: <p>I have a Azure SQL db that powers my webapp. </p>
  
  <p>There is a Web API 2.0 sitting in a virtual directory. </p>
  
  <p>My web app does some lightweight db stuff, the API is responsible for entering data in and the webapp part is for users to log in and view their tracked email data. </p>
  
  <p>Pretty simple stuff. </p>
  
  <p>Now the problem seems to be the db. I keep getting these pesky Sql Timeout errors. </p>
  
  <p>The weird thing is, it's the same error all throughout. I should mention that the <code>webapi</code> is built using NHibernate. The web portal is <em>mainly</em> Entity Framework using Code First. </p>
  
  <p>I've contacted some SQL "experts" from Microsoft, and the only helpful information that they've provided me is that they've pointed out every time I get these intermittent timeout erros, the "writelog" has spiked up immediately. </p>
  
  <p>Now this presents a problem because I do not know how to diagnose this issue. </p>
  
  <p>I'm pasting the "generic" stack trace so I can illicit some helpful info from anyone on here whose a SQL Azure expert. </p>
  
  <p>Stack Trace: </p>
  
  <p><code>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=2; handshake=9; [Login] initialization=0; authentication=0; [Post-Login] complete=1; ---&gt; System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)...</code>
  `</p>