title: Azure Function receiving duplicate messages from Event Grid
body: <p>I've a very simple Javascript Function App being sent messages from an Event Grid subscription with a filter. The function reliably gets <strong>two</strong> messages for every <strong>one</strong> that arrives at the IoT Hub that the Event Grid is being fed by.</p>
  <p>I've verified that it <em>is</em> only one message by also routing the same message to storage using the same filter (using IoT Hub Message Routing).</p>
  <p>I do not believe it's the timeout &quot;error&quot; I see noted while searching on this: the function processes in 10-150ms and definitely isn't running against the 30 second retry timer. The repeated messages come in within milliseconds of each other, the second immediately following the first.</p>
  <p>Also, the messages are byte-for-byte identical, and they have the same trigger timestamp and Id:</p>
  <p><code>Executing 'Functions.processLocationSetupMsg' (Reason='EventGrid trigger fired at 2020-12-01T02:08:14.6659970+00:00', Id=2734288c-c758-4a8e-b843-d6b12d0304b7)</code></p>
  <p>The function is basically from the docs and looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>module.exports = async function(context, eventGridEvent) {
      let out = (eventGridEvent.data.body &amp;&amp; eventGridEvent.data.body.model) ?
          eventGridEvent.data.body.model :
          &quot;model not defined&quot;
      context.log(`&gt;&gt;&gt; JavaScript eventgrid trigger function called for message: ${out}`);
  
      context.log(JSON.stringify(eventGridEvent, null, 2))
  };
  </code></pre>
  <p>I have also tried the non-async style using <code>context.done()</code>, too.</p>
  <p>The Event Subscription Filter is <code>data.body.model</code> <code>string begins with</code> <code>locationSetup</code>.</p>
  <p>Any thoughts how I might get this down to just one message as expected?</p>