Microsoft.Azure.WebJobs.Extensions.EventGrid 3.4.4

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Microsoft.Azure.WebJobs.Extensions.EventGrid --version 3.4.4
NuGet\Install-Package Microsoft.Azure.WebJobs.Extensions.EventGrid -Version 3.4.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version ofInstall-Package.
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="3.4.4" />
For projects that supportPackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="3.4.4" />
Directory.Packages.props
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" />
Project file
For projects that supportCentral Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Azure.WebJobs.Extensions.EventGrid --version 3.4.4
The NuGet Team does not provide support for this client. Please contact itsmaintainers for support.
#r "nuget: Microsoft.Azure.WebJobs.Extensions.EventGrid, 3.4.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Microsoft.Azure.WebJobs.Extensions.EventGrid&version=3.4.4
Install as a Cake Addin
#tool nuget:?package=Microsoft.Azure.WebJobs.Extensions.EventGrid&version=3.4.4
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact itsmaintainers for support.

Azure WebJobs EventGrid client library for .NET

This extension provides functionality for receiving Event Grid webhook calls in Azure Functions, allowing you to easily write functions that respond to any event published to Event Grid.

Getting started

Install the package

Install the Event Grid extension withNuGet:

dotnet add package Microsoft.Azure.WebJobs.Extensions.EventGrid

Prerequisites

You must have anAzure subscription and an Azure resource group with a custom Event Grid topic or domain. Follow thisstep-by-step tutorial to register the Event Grid resource provider and create Event Grid topics using theAzure portal. There is asimilar tutorial usingAzure CLI.

Authenticate the Client

In order for the extension publish events, you will need theendpoint of the Event Grid topic and acredential, which can be created using the topic's access key.

You can find the endpoint for your Event Grid topic either in theAzure Portal or by using theAzure CLI snippet below.

az eventgrid topic show --name <your-resource-name> --resource-group <your-resource-group-name> --query "endpoint"

The access key can also be found through theportal, or by using the Azure CLI snippet below:

az eventgrid topic key list --name <your-resource-name> --resource-group <your-resource-group-name> --query "key1"

Key concepts

Using Event Grid output binding

Please follow thebinding tutorial to learn about using this extension for publishing EventGrid events.

Using Event Grid trigger

Please follow thetutorial to learn about triggering an Azure Function when an event is published.

Examples

Functions that uses Event Grid output binding

If you are using the EventGrid schema for your topic, you can output EventGridEvents.

public static class EventGridEventBindingFunction{    [FunctionName("EventGridEventBindingFunction")]    public static async Task<IActionResult> RunAsync(        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,        [EventGrid(TopicEndpointUri = "EventGridEndpoint", TopicKeySetting = "EventGridKey")] IAsyncCollector<EventGridEvent> eventCollector)    {        EventGridEvent e = new EventGridEvent(await req.ReadAsStringAsync(), "IncomingRequest", "IncomingRequest", "1.0.0");        await eventCollector.AddAsync(e);        return new OkResult();    }}

If you are using the CloudEvent schema for your topic, you can output CloudEvents.

public static class CloudEventBindingFunction{    [FunctionName("CloudEventBindingFunction")]    public static async Task<IActionResult> RunAsync(        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,        [EventGrid(TopicEndpointUri = "EventGridEndpoint", TopicKeySetting = "EventGridKey")] IAsyncCollector<CloudEvent> eventCollector)    {        CloudEvent e = new CloudEvent("IncomingRequest", "IncomingRequest", await req.ReadAsStringAsync());        await eventCollector.AddAsync(e);        return new OkResult();    }}

It is also possible to use Azure Identity with the output binding. To do so, set theConnection property to the name of your app setting that contains your Event Grid Topic endpoint along with a set of optional Identity information that is described in detailhere. When setting theConnection property, theTopicEndpointUri andTopicKeySetting properties should NOT be set.

public static class CloudEventOutputBindingWithIdentityFunction{    [FunctionName("CloudEventOutputBindingWithIdentityFunction")]    public static async Task<IActionResult> RunAsync(        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,        [EventGrid(Connection = "MyConnection")] IAsyncCollector<CloudEvent> eventCollector)    {        CloudEvent e = new CloudEvent("IncomingRequest", "IncomingRequest", await req.ReadAsStringAsync());        await eventCollector.AddAsync(e);        return new OkResult();    }}

For local development, use thelocal.settings.json file to store the connection information:

{  "Values": {    "myConnection__topicEndpointUri": "{topicEndpointUri}"  }}

When deployed, use theapplication settings to store this information.

You can also output a string or JObject and the extension will attempt to parse into the correct strongly typed event.

Functions that uses Event Grid trigger

You can also create a function that will be executed whenever an event is delivered to your topic. Depending on the schema you have selected for your Azure Function event subscription, you can bind to eitherEventGridEvent orCloudEvent:

public static class EventGridEventTriggerFunction{    [FunctionName("EventGridEventTriggerFunction")]    public static void Run(        ILogger logger,        [EventGridTrigger] EventGridEvent e)    {        logger.LogInformation("Event received {type} {subject}", e.EventType, e.Subject);    }}

And if your subscription is configured with the CloudEvent schema:

public static class CloudEventTriggerFunction{    [FunctionName("CloudEventTriggerFunction")]    public static void Run(        ILogger logger,        [EventGridTrigger] CloudEvent e)    {        logger.LogInformation("Event received {type} {subject}", e.Type, e.Subject);    }}

It is also possible to bind to an array of events. This is useful if you havebatching enabled for your Event Grid Subscription.

public static class EventGridEventBatchTriggerFunction{    [FunctionName("EventGridEventBatchTriggerFunction")]    public static void Run(        ILogger logger,        [EventGridTrigger] EventGridEvent[] events)    {        foreach (EventGridEvent eventGridEvent in events)        {            logger.LogInformation("Event received {type} {subject}", eventGridEvent.EventType, eventGridEvent.Subject);        }    }}

Similarly, for subscriptions configured with the CloudEvent schema:

public static class CloudEventBatchTriggerFunction{    [FunctionName("CloudEventBatchTriggerFunction")]    public static void Run(        ILogger logger,        [EventGridTrigger] CloudEvent[] events)    {        foreach (CloudEvent cloudEvent in events)        {            logger.LogInformation("Event received {type} {subject}", cloudEvent.Type, cloudEvent.Subject);        }    }}

Troubleshooting

Please refer toMonitor Azure Functions for troubleshooting guidance.

Next steps

Read theintroduction to Azure Function orcreating an Azure Function guide.

Contributing

See ourCONTRIBUTING.md for details on building,testing, and contributing to this library.

This project welcomes contributions and suggestions. Most contributions requireyou to agree to a Contributor License Agreement (CLA) declaring that you havethe right to, and actually do, grant us the rights to use your contribution. Fordetails, visitcla.microsoft.com.

This project has adopted theMicrosoft Open Source Code of Conduct.For more information see theCode of Conduct FAQor contactopencode@microsoft.com with anyadditional questions or comments.

ProductCompatible and additional computed target framework versions.
.NETnet5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. 
.NET Corenetcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. 
.NET Standardnetstandard2.0 is compatible. netstandard2.1 was computed. 
.NET Frameworknet461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. 
MonoAndroidmonoandroid was computed. 
MonoMacmonomac was computed. 
MonoTouchmonotouch was computed. 
Tizentizen40 was computed. tizen60 was computed. 
Xamarin.iOSxamarinios was computed. 
Xamarin.Macxamarinmac was computed. 
Xamarin.TVOSxamarintvos was computed. 
Xamarin.WatchOSxamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more aboutTarget Frameworks and.NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Microsoft.Azure.WebJobs.Extensions.EventGrid:

PackageDownloads
Microsoft.Azure.Workflows.WebJobs.Extension

Extensions for running workflows in Azure Functions

Reimaginate.DataHub.AzureFunctionAgentHost

Package Description

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on Microsoft.Azure.WebJobs.Extensions.EventGrid:

RepositoryStars
Azure-Samples/Serverless-microservices-reference-architecture
This reference architecture walks you through the decision-making process involved in designing, developing, and delivering a serverless application using a microservices architecture through hands-on instructions for configuring and deploying all of the architecture's components along the way. The goal is to provide practical hands-on experience in working with several Azure services and the technologies that effectively use them in a cohesive and unified way to build a serverless-based microservices architecture.
microsoft/IgniteTheTour
Microsoft Ignite The Tour
Azure-Samples/azure-digital-twins-unreal-integration
Sample project demonstrating the Unreal Engine plug-in for Azure Digital Twins
MerrionComputing/EventsSourcing-on-Azure-Functions
A library to demonstrate doing Event Sourcing as a data persistence mechanism for Azure Functions
VersionDownloads Last Updated
3.5.0 4,8786/20/2025
3.4.4 114,1653/14/2025
3.4.3 149,60711/19/2024
3.4.2 779,5317/31/2024
3.4.1 194,6774/17/2024
3.3.1 1,162,32211/13/2023
3.3.0 721,2186/15/2023
3.2.1 1,447,5119/8/2022
3.2.0 1,279,5304/21/2022
3.1.0 566,3151/13/2022
3.0.1 154,27112/14/2021
3.0.0 165,72510/26/2021
3.0.0-beta.4 14,41710/11/2021
3.0.0-beta.3 323,4306/9/2021
3.0.0-beta.2 18,7545/13/2021
3.0.0-beta.1 21,6123/23/2021
2.1.0 3,678,42510/19/2019
2.0.0 777,6289/19/2018
2.0.0-rc1 1,7569/14/2018
2.0.0-beta4 6,1228/30/2018
2.0.0-beta3 1,1788/30/2018
2.0.0-beta2 2,6867/6/2018
2.0.0-beta1 6,8713/30/2018
1.0.0 211,1977/6/2018
1.0.0-beta4 52,7184/4/2018
1.0.0-beta3 5,6193/1/2018
1.0.0-beta2 5,1019/25/2017
1.0.0-beta1-10006 1,2158/16/2017
1.0.0-beta1 1,4359/25/2017
Downloads
Total11.9M
Current version114.2K
Per day average4.1K
About
Owners

© Microsoft Corporation. All rights reserved.

Share this package on FacebookShare this package on XUse the Atom feed to subscribe to new versions of Microsoft.Azure.WebJobs.Extensions.EventGrid