title | description | author | ms.topic | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|
Azure Event Grid bindings for Azure Functions |
Understand how to handle Event Grid events in Azure Functions. |
craigshoemaker |
reference |
02/14/2020 |
cshoe |
fasttrack-edit |
This reference explains how to handle Event Grid events in Azure Functions. For details on how to handle Event Grid messages in an HTTP end point, see Receive events to an HTTP endpoint.
Event Grid is an Azure service that sends HTTP requests to notify you about events that happen in publishers. A publisher is the service or resource that originates the event. For example, an Azure blob storage account is a publisher, and a blob upload or deletion is an event. Some Azure services have built-in support for publishing events to Event Grid.
Event handlers receive and process events. Azure Functions is one of several Azure services that have built-in support for handling Event Grid events. In this reference, you learn to use an Event Grid trigger to invoke a function when an event is received from Event Grid, and to use the output binding to send events to an Event Grid custom topic.
If you prefer, you can use an HTTP trigger to handle Event Grid Events; see Receive events to an HTTP endpoint. Currently, you can't use an Event Grid trigger for an Azure Functions app when the event is delivered in the CloudEvents schema. Instead, use an HTTP trigger.
Action | Type |
---|---|
Run a function when an Event Grid event is dispatched | Trigger |
Sends an Event Grid event | Output binding |
The code in this reference defaults to .NET Core syntax, used in Functions version 2.x and higher. For information on the 1.x syntax, see the 1.x functions templates.
Working with the trigger and bindings requires that you reference the appropriate package. The NuGet package is used for .NET class libraries while the extension bundle is used for all other application types.
Language | Add by... | Remarks |
---|---|---|
C# | Installing the NuGet package, version 2.x | |
C# Script, Java, JavaScript, Python, PowerShell | Registering the extension bundle | The Azure Tools extension is recommended to use with Visual Studio Code. |
C# Script (online-only in Azure portal) | Adding a binding | To update existing binding extensions without having to republish your function app, see Update your extensions. |
A new version of the Event Grid bindings extension is available as a preview NuGet package. For .NET applications, it changes the types that you can bind to, replacing the types from Microsoft.Azure.EventGrid.Models
with newer types from Azure.Messaging.EventGrid. Cloud events are also supported in the new Event Grid extension.
Note
The preview package is not included in an extension bundle and must be installed manually. For .NET apps, add a reference to the package. For all other app types, see Update your extensions.
Functions 1.x apps automatically have a reference the Microsoft.Azure.WebJobs NuGet package, version 2.x.