title: Azure Function with Servicebus binding Exceptions
body: <p>We have an Azure Function with a ServiceBus binding (Topic/Subscription) which gets triggered when new messages are put on the Service bus.</p>
  
  <p>We occasionally (once a day) see exception in Application Insights of the Azure Function related to the Service Bus. It doesn't seem to have any connection with our code in the Azure Function it self, but looks like some underlying connection issue.</p>
  
  <p>What should we do with these errors and how to solve/overcome them?</p>
  
  <p>Some examples:</p>
  
  <pre><code> Microsoft.ServiceBus.Messaging.MessagingException:
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver+ReceiveAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__12_5 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.OnEndTryReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver+RetryReceiveAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__15_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver+RetryReceiveAsyncResult.TryReceiveEnd (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver.EndTryReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver.EndReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceivePump+PumpAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__7_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  Inner exception System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] handled at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand:
     at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.ThrowIfFaultMessage (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.HandleMessageReceived (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel+RequestAsyncResult+&lt;&gt;c__DisplayClass8_1.&lt;GetAsyncSteps&gt;b__4 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  </code></pre>
  
  <p>And another example:</p>
  
  <pre><code>Microsoft.ServiceBus.Messaging.MessagingCommunicationException:
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver+RetryReceiveAsyncResult.TryReceiveEnd (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver.EndTryReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceiver.EndReceive (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.MessageReceivePump+PumpAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__7_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  Inner exception System.ServiceModel.CommunicationObjectFaultedException handled at Microsoft.ServiceBus.Common.AsyncResult.End:
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement+DuplexRequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel+RequestAsyncResult+&lt;&gt;c__DisplayClass8_1.&lt;GetAsyncSteps&gt;b__4 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement+RedirectContainerChannelFactory`1+RedirectContainerSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel+RequestAsyncResult+&lt;&gt;c.&lt;GetAsyncSteps&gt;b__9_3 (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Common.AsyncResult`1.End (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement+ReconnectChannelFactory`1+RequestSessionChannel.EndRequest (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.EndReceiveCommand (Microsoft.ServiceBus, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
  </code></pre>