Custom topics in Azure Event Grid

An event grid topic provides an endpoint where the source sends events. The publisher creates the event grid topic, and decides whether an event source needs one topic or more than one topic. A topic is used for a collection of related events. To respond to certain types of events, subscribers decide which topics to subscribe to.

Custom topics are application and third-party topics. When you create or are assigned access to a custom topic, you see that custom topic in your subscription.

When designing your application, you have flexibility when deciding how many topics to create. For large solutions, create a custom topic for each category of related events. For example, consider an application that sends events related to modifying user accounts and processing orders. It's unlikely any event handler wants both categories of events. Create two custom topics and let event handlers subscribe to the one that interests them. For small solutions, you might prefer to send all events to a single topic. Event subscribers can filter for the event types they want.

Event schema

For a detailed overview of event schema, see Azure Event Grid event schema. For custom topics, the event publisher determines the data object. The top-level data should have the same fields as standard resource-defined events.

[
  {
    "topic": string,
    "subject": string,
    "id": string,
    "eventType": string,
    "eventTime": string,
    "data":{
      object-unique-to-each-publisher
    },
    "dataVersion": string,
    "metadataVersion": string
  }
]

The following sections provide links to tutorials to create custom topics using Azure portal, CLI, PowerShell, and Azure Resource Manager (ARM) templates.

Azure portal tutorials

Title Description
Quickstart: create and route custom events with the Azure portal Shows how to use the portal to send custom events.
Quickstart: route custom events to Azure Queue storage Describes how to send custom events to a Queue storage.
How to: post to custom topic Shows how to post an event to a custom topic.

Azure CLI tutorials

Title Description
Quickstart: create and route custom events with Azure CLI Shows how to use Azure CLI to send custom events.
Azure CLI: create Event Grid custom topic Sample script that creates a custom topic. The script retrieves the endpoint and a key.
Azure CLI: subscribe to events for a custom topic Sample script that creates a subscription for a custom topic. It sends events to a WebHook.

Azure PowerShell tutorials

Title Description
Quickstart: create and route custom events with Azure PowerShell Shows how to use Azure PowerShell to send custom events.
PowerShell: create Event Grid custom topic Sample script that creates a custom topic. The script retrieves the endpoint and a key.
PowerShell: subscribe to events for a custom topic Sample script that creates a subscription for a custom topic. It sends events to a WebHook.

ARM template tutorials

Title Description
Resource Manager template: custom topic and WebHook endpoint A Resource Manager template that creates a custom topic and subscription for that custom topic. It sends events to a WebHook.
Resource Manager template: custom topic and Event Hubs endpoint A Resource Manager template that creates a subscription for a custom topic. It sends events to an Azure Event Hubs.

Next steps

See the following articles: