EventGridTrigger in Azure Functions

In general, the easiest way to integrate Azure Functions with Azure Event Grid is to use HttpTrigger:

[FunctionName("HttpTriggerCSharp")]public static async Task<HttpResponseMessage> Run(    [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req,     TraceWriter log){    (...)}

This is the most generic setup. It provides direct access to a request message and enables you to control its specific parts. There is, however, an alternative to the preceding setup—we can instead use EventGridTrigger:

[FunctionName("EventGridTriggerCSharp")]public static void Run([EventGridTrigger]JObject eventGridEvent, TraceWriter log){ log.Info(eventGridEvent.ToString(Formatting.Indented)); ...

Get Hands-On Azure for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.