title: Azure Functions Event hub read write latency spikes with StorageException and SocketException spikes
body: <p>We have a service in production that is suffering from Latency spikes. During these spikes we see we are getting a large amount of StorageExceptions and SocketExceptions
  <a href="https://i.stack.imgur.com/TDQnm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TDQnm.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/8ek4E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ek4E.png" alt="error count table" /></a></p>
  <p>These images are over a 4 hour time period.</p>
  <p>What more is, this only happens on our EUS instance of the service (which has approximetly 26 event hub triggers) and not on our WEU (7 event hub triggers) and Canary(EUS2 - 2 event hub triggers).</p>
  <p>The innermost error for the storage account exceptions we are seeing is:
  A lease ID was specified, but the lease for the blob has expired.
  which is known to be OK in small amounts - but 24.5K in 4 hours doesnt feel like small amounts and there is a direct correlation between the exception spikes and the latency spikes</p>
  <p>The innermost exception for the sockets is:
  An attempt was made to access a socket in a way forbidden by its access permissions.
  It also correlates nicely to the latency spikes.</p>
  <p>On the other hand events can be seen flowing through the service and to the receiving event hub through the entire 4 hour time period:
  <a href="https://i.stack.imgur.com/MsJZb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MsJZb.png" alt="enter image description here" /></a></p>
  <p>All the outgoing events are written to the same event hub in every cloud (3 total - 1 EUS, 1EUS2, 1WEU), where every cloud writes to its own eventhub accordingly.
  It also seems that the entire latency spike is due to the write action to the eventhub (which is done via eventhub name + FQDN AAD connection):
  <a href="https://i.stack.imgur.com/747P9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/747P9.png" alt="enter image description here" /></a></p>
  <p>Any help with this issue will be much appreciated!</p>