In this section, you will learn how to manage events using Event Grid.
Suppose you have a storage account and you want to log what happens inside it (the creation or deletion of blobs, containers, and so on) using an Azure function. To do this, you should go through the following steps:
- First of all, you must write your Azure function that implements the event handler:
[FunctionName("EventHandlerFunction")]
public static void EventGridHandler([EventGridTrigger]EventGridEvent eventGridEvent, ILogger log)
{
log.LogInformation(eventGridEvent.EventType);
log.LogInformation(eventGridEvent.Data.ToString());
}
The Azure function uses the EventGrid trigger to receive the event payload when it is called by Event Grid.
- You must reference the Microsoft.Azure.WebJobs.Extensions.EventGrid package to use the EventGridTrigger attribute.
When...