title: Azure function TimerTrigger result code in Application Insights is always success
body: <p>I've got a simple C# Azure Function using a timer trigger to run every X minutes. No output binding.</p>
  
  <p>In application insights, the function is always in <em>success</em> with a <em>result code</em> of 0:</p>
  
  <p><img src="https://tof.cx/images/2019/01/31/14dd3d8bfc65f36da714312c2fdcf84a.png" alt="Here"> </p>
  
  <p>[Despite having called the .Error() of the TraceWriter several times.]</p>
  
  <p>I'd like to get the correct final status in application insights but I don't see how to do it. Documentation never talks about that :-/
  Can someone guide me how to do it in C# ?</p>
  
  <p>I tried to set <code>Environment.ExiCode</code> but same result.
  I also tried to change return type to <code>int</code> but then the function isn't called anymore. I suppose because its the way to <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#c-example" rel="nofollow noreferrer">declare an output binding</a> for the azure function itself.</p>
  
  <p>Here is my function:</p>
  
  <pre><code>[FunctionName("SendToOfflineArchive")]
  public static void Run([TimerTrigger("%TimerInterval%")]TimerInfo myTimer, TraceWriter log)
  {
      log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
  
      // do stuff
  
      int nbErrors = 7;
      //return nbErrors;
  }
  </code></pre>
  
  <p>It would be great to have a result code other than 0... Like the number of errors (an integer).</p>