| [ Web Proxy ] |
| Viewing: https://learn.microsoft.com/en-us/azure/event-grid/handler-functions | [Back] [Original] |
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
An event handler is the place where the event is sent. The handler takes an action to process the event. Several Azure services are automatically configured to handle events and Azure Functions is one of them. For instance, Azure Event Grid can utilize Azure Functions as an anti-corruption layer to transform or validate events before forwarding them to downstream systems.
To use a function in Azure as a handler for events, follow one of these approaches:
We recommend that you use the first approach (Event Grid trigger) as it has the following advantages over the second approach:
Note
| Title | Description |
|---|---|
| Quickstart: Handle events with function | Sends a custom event to a function for processing. |
| Tutorial: stream big data into a data warehouse | When an event hub creates a Capture file, Event Grid sends an event to a function app. The app retrieves the Capture file and migrates data to a data warehouse. |
| Tutorial: Azure Service Bus to Azure Event Grid integration examples | Event Grid sends messages from Service Bus topic to a function app and a logic app. |
{
"properties":
{
"destination":
{
"endpointType": "AzureFunction",
"properties":
{
"resourceId": "/subscriptions/<AZURE SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Web/sites/<FUNCTION APP NAME>/functions/<FUNCTION NAME>",
"maxEventsPerBatch": 10,
"preferredBatchSizeInKilobytes": 64
}
},
"eventDeliverySchema": "EventGridSchema"
}
}
For a higher throughput, enable batching on the subscription. If you're using the Azure portal, you can set maximum events per batch and the preferred batch size in kilo bytes at the time of creating a subscription or after the creation.
You can configure batch settings using the Azure portal, PowerShell, CLI, or Resource Manager template.
At the time creating a subscription in the UI, on the Create Event Subscription page, switch to the Advanced Features tab, and set values for Max events per batch and Preferred batch size in kilobytes.
[Enable batching at the time of creating a subscription]
You can update these values for an existing subscription on the Features tab of the Event Grid Topic page.
[Enable batching after creation]
You can set maxEventsPerBatch and preferredBatchSizeInKilobytes in an Azure Resource Manager template. For more information, see Microsoft.EventGrid eventSubscriptions template reference.
You can use the az eventgrid event-subscription create command to configure batch-related settings using the following parameters: --max-events-per-batch or --preferred-batch-size-in-kilobytes.
You can use the New-AzEventGridSubscription or Update-AzEventGridSubscription cmdlet to configure batch-related settings using the following parameters: -MaxEventsPerBatch or -PreferredBatchSizeInKiloBytes.
Note
When you use Event Grid Trigger, the Event Grid service fetches the client secret for the target Azure function, and uses it to deliver events to the Azure function. If you protect your Azure function with a Microsoft Entra application, you have to take the generic web hook approach and use the HTTP Trigger.
See the Event handlers article for a list of supported event handlers.
Was this page helpful?
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?