March 29, 2024

Azure Event Grid Overview

Event Grid allows you to implement event-based architectures.

Concepts

Events

Every event is comprised of common information such as event source, time of event, and unique id. The event may also contain custom information based on the type of the event. For example, if a file was created on the Azure Storage, then the event may contain the URL of that file. The maximum allowed size for an event is 1 MB. Events over 64 KB are charged in 64 KB increments.

Event Grid Schema:

Publisher – sends events to the Event Grid.

Event Sources – Is where the event occurs. Event sources are responsible for sending events to Event Grid.

Topics

This is an endpoint where event sources can publish events to. A topic is used for a collection of related events. Subscribers can choose which topics to subscribe to.

Types of topics:

System topics – are built-in topics provided by Azure Services. You can also create system level topics in your Azure Subscription and subscribe to them.

Custom topics – You can create a custom topic for each category of related events. Event subscribers can filter for the events types they are interested in.

Partner topic – Allows third party SaaS providers to publish events from its services to make them available to consumers who can subscribe to those events.

Event subscriptions

When creating a subscription, you must provide an endpoint for handling events. You can filter the events that are sent to the endpoint. You can filter by event type, or subject pattern. (Read https://docs.microsoft.com/en-us/azure/event-grid/subscription-creation-schema).

You can also specify expiration dates for event subscriptions. This is useful for temporary subscriptions and services with known lifetimes.

Batching – Custom events must be published in an array. This allows batching of events. Batches can be up to 1 MB.

Useful links

.NET Azure Event Grid library – https://docs.microsoft.com/en-us/dotnet/api/overview/azure/eventgrid

Azure Event Grid REST API – https://docs.microsoft.com/en-us/rest/api/eventgrid/

Filter events – https://docs.microsoft.com/en-us/azure/event-grid/how-to-filter-events

Receive events at an HTTP endpoint (WebHook) – https://docs.microsoft.com/en-us/azure/event-grid/receive-events