title: Message from servicebus queue disappears on error in activity function
body: <p>I have developed an Azure Durable Functions app that triggers on new servicebus queue messages. It works ok when no errors occurs, but when an error occurs in an activity function, it logs that it fails but the message is gone forever from the queue. What could be causing that, and how do I prevent the message from disappearing from the queue on error?</p>
  
  <p>Here is the reproducable code, it's the code generated from a new Azure Function template in VS2017, only an exception is added when the city is "Seattle", and it's a ServicebusTrigger instead of a HttpTrigger.</p>
  
  <pre><code>            [FunctionName("Test")]
      public static async Task&lt;List&lt;string&gt;&gt; RunOrchestrator(
          [OrchestrationTrigger] DurableOrchestrationContext context)
      {
          var outputs = new List&lt;string&gt;();
  
          // Replace "hello" with the name of your Durable Activity Function.
          outputs.Add(await context.CallActivityAsync&lt;string&gt;("Test_Hello", "Tokyo"));
          outputs.Add(await context.CallActivityAsync&lt;string&gt;("Test_Hello", "Seattle"));
          outputs.Add(await context.CallActivityAsync&lt;string&gt;("Test_Hello", "London"));
  
          // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
          return outputs;
      }
  
      [FunctionName("Test_Hello")]
      public static string SayHello([ActivityTrigger] string name, ILogger log)
      {
          log.LogInformation($"Saying hello to {name}.");
          if (name == "Seattle")
              throw new Exception("An error occurs");
          return $"Hello {name}!";
      }
  
      [FunctionName("Test_HttpStart")]
      public static async Task ServiceBusStart(
          [ServiceBusTrigger("somequeue", Connection = "ServiceBusQueueListenerConnectionString")]string queuemsg,
          [OrchestrationClient]DurableOrchestrationClient starter,
          ILogger log)
      {
          // Function input comes from the request content.
          var msg = JsonConvert.DeserializeObject&lt;IncomingMessage&gt;(queuemsg);
          string instanceId = await starter.StartNewAsync("Test", msg);
          log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
      }
  </code></pre>
  
  <p>Update: When I have the exception in the Orchestration client function, it does the right thing like retrying and putting the message on the dead letter queue if retrying fails x times.</p>
  
  <p>So I managed to work around this by updating the client function with this while loop, checking for failed/terminated/canceled status.</p>
  
  <pre><code>    [FunctionName("Test_HttpStart")]
      public static async Task ServiceBusStart(
          [ServiceBusTrigger("somequeue", Connection = "ServiceBusQueueListenerConnectionString")]string queuemsg,
          [OrchestrationClient]DurableOrchestrationClient starter,
          ILogger log)
      {
          // Function input comes from the request content.
          var msg = JsonConvert.DeserializeObject&lt;IncomingMessage&gt;(queuemsg);
          string instanceId = await starter.StartNewAsync("Test", msg);
          log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
  
          var status = await starter.GetStatusAsync(instanceId);
  
          while (status.RuntimeStatus != OrchestrationRuntimeStatus.Completed)
          {
              System.Threading.Thread.Sleep(1000);
              status = await starter.GetStatusAsync(instanceId);
              if (status.RuntimeStatus == OrchestrationRuntimeStatus.Failed 
                  || status.RuntimeStatus == OrchestrationRuntimeStatus.Terminated
                  || status.RuntimeStatus == OrchestrationRuntimeStatus.Canceled)
              {
                  throw new Exception("Orchestration failed with error: " + status.Output);
              }
          }
  
      }
  </code></pre>
  
  <p>However it seems like a hack to me, and I have not seen this type of code in any MS example code. I guess this should be taken care of by the durable functions framework. Is there another way to make the servicebus trigger work in durable functions?</p>