1
votes

@azuresupport #azTechHelp I have an event grid topic with an Azure Function subscriber that has a CosmosDB output binding. Here is the function

export default async (context, eventGridEvent) => {

    try {

        context.log(`Saving Asset`);
        context.log(`subject : ${eventGridEvent.subject}`)
        context.log(`eventType : ${eventGridEvent.eventType}`)

        var importObject = eventGridEvent.data;

        if(!importObject.asset.id)
        {
            throw new Error("Supplied Asset does not have an ID specified, aborting!");
        }
        else
        {
            context.log(`Successfully exported asset(${eventGridEvent.data.objectId}) to Cosmos`);
            context.bindings.outputDocument = importObject.asset;
        }

    }
    catch (err) {
        context.log.error(err);
        context.log.error(`Error Processing Event Grid Object : ${eventGridEvent}`);
        throw(err);
    }
};

The logic in this function will (generally) never fail, however the Cosmos DB binding can fail (and is failing due to a throughput limit). So the function fails, but thats ok our Event Grid will retry, right? Wrong!

Image : Azure Function Failures

The problem is that the Event Grid doesn't register the failure and in turn never retries the event.

Image : EG Logs

Now we can code the function to do the Cosmos CRUD inside the function and force the error, or maybe create our own binding but we would like to stick with the built in Cosmos binding.

Can someone in Azure take a look pls?

1
Do you need to add a context.done in the above code? docs.microsoft.com/en-us/azure/azure-functions/… - J. Kalyana Sundaram

1 Answers

0
votes

This is likely because once event reached Azure function, it was considered a delivered success and the outcome of the function execution didn't not contribute to the http response

It was a known issue and fixed in lastest eventgrid extension release, I would say you should get in a week or two, if not, please open an issue here