I'm trying to understand the behavior of EventGrid when using EventGridTrigger in Azure Function v2 functions. This page (in MS official docs), details specific behavior related to status codes returned from event handlers, but it doesn't specifically say what type of event handler is being used. I can only assume based on the use of the status codes that it is intended for webhook use. However, the subscription configuration in the Azure portal has an event handler for Azure Functions. How would one trigger those specific behaviors from the azure function when using this event handler? Also, what are the differences of using this as opposed a standard webhook event handler? I have found several mentions of "additional functionality" that is provided by the Azure Function event handler but I can't seem to find any documentation detailing anything specific.
1 Answers
Basically, the Message delivery status can be programmatically handled only by the endpoint types such as WebHook and HybridConnection.
In the case of EventGridTrigger, the handler allows to throw an exception only for retrying a message delivery. In other words, there is no exception type to force the BadRequest status code which immediately is triggering a process of the deadlettering (if deadleatter is configured).
Beside that, the EventGridTrigger function doesn't flow useful aeg headers and currently version can not handled a message with a delivery schema = CloudEventSchemaV1_0.
Note, that the WebHook and HybridConnection handlers have a responsibility to built a response for validation handshake call. The Azure Function handler has this validation logic built in the preprocessor of the EventGridTrigger (currently only for EventGridSchema and CustomInputSchema)
Update:
The AEG eventing sent to the endpoint handler the following aeg headers:
aeg-subscription-name=MYSUBSCRIPTION
aeg-delivery-count=0
aeg-data-version=1.0
aeg-metadata-version=1
aeg-event-type=Notification
The aeg headers can be helped for additional feature of the event handler, for example; long running process, fan-in pattern, etc.