question

39551769 avatar image
1 Vote"
39551769 asked PramodValavala-MSFT commented

Why using an Event Grid between an Azure Function and a Service Bus or an Event Hub ?

Hello,

I just checked some tutorials from the Microsoft documentation, then I think I'm missing a point.
It is possible to bind an Azure Function directly to a Service Bus or an Event Hub. So, what is the benefit to use an Event Grid Trigger then query the Service Bus or the Event Hub in response to that event ?

First example here, using an Event Grid between a Service Bus and an Azure Function : https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-to-event-grid-integration-function (the same tutorial exists for a Logic App, which also have a Service Bus integration).
Another example here, using an Event Grid between an Event Hub and an Azure Function : https://docs.microsoft.com/en-us/azure/event-grid/event-grid-event-hubs-integration

I tried to find some explanations but without success. Is there a specific documentation where I can find informations about that method ?

Thanks a lot
Alexandre

azure-event-hubsazure-service-busazure-event-grid
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PramodValavala-MSFT avatar image
1 Vote"
PramodValavala-MSFT answered PramodValavala-MSFT commented

@AlexandreMasson-2318 Behind the scenes, the scale controller monitors sources for events/messages to decide whether to scale a function app out by adding more instances. This is usually achieved by polling the source which counts towards pricing/throughput depending on the service.

If you have an Event Hub or Service Bus that doesn't have a constant in flow of messages, you could switch to using the Event Grid trigger which triggers the function app only when there are messages with no active listeners.

A beneficial use case for this could be for dead letter queues that need listeners only in case of failures.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you @PramodValavala-MSFT that make sense, I didn't think about the scale controller.

I wonder however, when an Event Grid is used between an Azure Function and an Event Hub (like in the "Stream big data into a data warehouse" tutorial), as we receive one event for each capture file event, this can lead to a lot of events. Is the Azure Function capable of auto scale with an EventGridTrigger ? Because we can't poll anything in that situation.

0 Votes 0 ·

@49715321 Yes. The Event Grid Trigger functions like the HTTP trigger and will scale the function out as appropriate.

1 Vote 1 ·