title: Azure Functions - waiting for context.log
body: <p>I'm seeing a lot of the following when I'm doing a <code>context.log</code> in my Azure Function - timed trigger:</p>
  
  <blockquote>
    <p>Warning: Unexpected call to 'log' on the context object after function execution has completed. Please check for asynchronous calls that are not awaited or calls to 'done' made before function execution completes</p>
  </blockquote>
  
  <p>I think it is happening because the return gets called before that <code>context.log</code> has fully executed.</p>
  
  <p>But could someone kindly confirm/help explain. </p>
  
  <pre><code>export async function onTrigger(context: Context, myTimer: any): Promise&lt;void&gt; {
      async getJobs(context);
  }
  
  async function getJobs(context: Context): Promise&lt;void&gt; {
      try {
         const response = await axios.get("http://localhost:8111/batches");
         processBatch(context, response);
      } catch (error) {
         context.log.error(`Some Error Log`, error);
      }
  }
  
  async function processBatch(context: Context, response: any) {
      //… Some stuff
  
      if (stableStates.includes(someStatus)) {
         context.log("Some Message")
         return;
      }
  }
  </code></pre>