Azure Function receiving duplicate messages from Event Grid

Ken Martin 111 Reputation points
2020-12-01T19:11:34.69+00:00

I've a very simple Javascript Function App being sent messages from an Event Grid subscription with a filter. The function reliably gets two messages for every one that arrives at the IoT Hub that the Event Grid is being fed by.

I've verified that it is only one message by also routing the same message to storage using the same filter (using IoT Hub Message Routing).

I do not believe it's the timeout "error" 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.

Also, the messages are byte-for-byte identical, and they have the same trigger timestamp and Id:

Executing 'Functions.processLocationSetupMsg' (Reason='EventGrid trigger fired at 2020-12-01T02:08:14.6659970+00:00', Id=2734288c-c758-4a8e-b843-d6b12d0304b7)

The function is basically from the docs and looks like this:

module.exports = async function(context, eventGridEvent) {
    let out = (eventGridEvent.data.body && eventGridEvent.data.body.model) ?
        eventGridEvent.data.body.model :
        "model not defined"
    context.log(`>>> JavaScript eventgrid trigger function called for message: ${out}`);

    context.log(JSON.stringify(eventGridEvent, null, 2))
};

I have also tried the non-async style using context.done(), too.

The Event Subscription Filter is data.body.model string begins with locationSetup.

Any thoughts how I might get this down to just one message as expected?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,257 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,115 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
313 questions
{count} votes