How to use Azure Event Grid Custom Topic | Publishing and Subscribing from Azure Event Grid Custom Topic using Logic App

{tocify} $title={Table of Contents}


One of the thing we need to identify while starting with any Integration project is whether the scenario demands for message based integration or event based integration.

When there is need to sync the systems and data is involved, message based integration should be designed, whereas when some action is to be taken based on some state change then event based integration should be used.

Message : Set of data produced by a system.

Event : Is a notification about some objects state change. 

As per the need, integration can be build around messages or events or in some cases both can be used.

To cater this, Azure has three options/services to choose from
  • Azure Event Grid
  • Azure Event Hubs
  • Azure Service Bus
Let's see about event grid and how it can be used.

What is Event Grid

It is a service from Azure which allows various entities/services/application to publish the state change notification to it and also to deliver those to them who are interested in knowing about it.

The real work of the Event grid is to route the events, and it does it with help of Publish and Subscribe methodology.

Thus you can use Event Grid when there is need to integrate applications based on events.

So any application can send(publish) events to Event grid and any application can receive(subscribe) to those events.

Event Grid has inbuilt support for almost all azure services through system topics, but it also does supports integration of non Azure services/application through Custom Topics.

Terminologies used in context to Event Grid are:


An event is the information that describes something that happened in the system. 

The maximum allowed size for an event is 1 MB. 


A publisher is the user or organization that sends events to Event Grid. Microsoft publishes events for several Azure services. You can publish events from your own application. Organizations that host services outside of Azure can publish events through Event Grid.

Event sources

An event source is where the event happens.

Your application is the event source for custom events that you define. Event sources are responsible for sending events to Event Grid.


Topic provides an endpoint where the source sends events. 

System topics

System topics are built-in topics provided by Azure services such as Azure Storage, Azure Event Hubs, and Azure Service Bus. You can create system topics in your Azure subscription and subscribe to them. 

Custom topics

Custom topics are application and third-party topics. Event subscribers can filter for the event types they want.

Event subscriptions

A subscription tells Event Grid which events on a topic you're interested in receiving. 

When creating the subscription, you provide an endpoint for handling the event. You can filter the events that are sent to the endpoint by event type or event subject.

Event handlers

An event handler is the place where the event is sent. 

Let's see through a demonstration how we can use Event grid custom Topic with one logic app as publisher and other as subscriber.

Note: For demo I have used Logic app, but it can be done same way with any custom application.

Create Event Grid Custom Topic

Create custom Event grid topic


Created Custom Topic

Now the Event grid custom topic is created, and with the help of Topic endpoint we can push events to this Custom Topic

Create Logic App to publish events to above created Custom Event Grid Topic

Publisher LA

Keeping it simple, using Recurrence trigger to trigger this logic app.

Click on new step and search for Event Grid, select  event grid publish action

Add event grid publish action

Create connection by providing the Topic endpoint and access key Event grid custom topic access key

To get access key, go to the Event Grid Custom topic you created -> Settings->Access Keys. And copy either of the key and provide it against Shared access signature.

Create connection to Event Grid Custom topic in logic app

After connection is successful, you can provide info about the event you want to publish.

Note: ID has to be unique, thus used guid() function.

configuring publish event action

The publisher to Event grid custom topic is created, and with the help of  this logic app we can push events to this Custom Topic.

Now, let's create a subscriber to this events.

Create Logic App to subscribe to the events published to above created Custom Event Grid Topic

Subscriber logic app

Add a http trigger , followed by a variable to hold the content received by the trigger

subscriber la design

Now, the subscriber is also ready. The final step is to create a subscription on custom topic.

Copy the HTTP Post URL and save as this will be used while creating subscription.

Create Event subscription on Custom Event Grid Topic

Go to the overview page of custom Event grid topic and  click on +Event Subscription

Create Event Subscription

Provide the meaningful name to the subscription as many subscriptions can be created on same topic.

Against Event Types provide the EventType you want to get (here DemoType as that's what we will publish and want it to be subscribed by Subscriber logic app) .

In Endpoint Details section, select Webhook as Endpoint type (the other options available are Azure Function, Storage queues, Event hubs, Hybrid connections, service bus queue, Service bus topic, Partner Destination) and against Endpoint provide the HTTP Post URL of above subscriber Logic App.

Click on create and that's it, Event Subscription is ready.

Logic App Event Grid Subscription

Note: There are other Tabs also to do advanced configuration. But for demo limiting it to Basics. 


Manually triggered the Publisher Logic App, and checked the run history

Publisher Logic App publishing event

And then checked the Subscriber logic app, it was triggered immediately and checked it's run history to validate the content
Subscriber Logic App getting trigger by event

To check if the event was passed through event grid, go to overview and check the metric

Event grid topic metric

For advanced metrics go to  Monitoring section and select Metrics, here you can choose from various metric options.


We saw basics of how we can leverage Event grid custom topic to create a event based integration solution, will post about advanced features in future.

Although I have used Logic app for demo, but any custom application can do the same.

Any application can publish to custom topic with the help of Topic endpoint and access key .

And any application can subscribe to events with the help of Webhook.

Learn More about Logic App

Post a Comment

If you have any suggestions or questions or want to share something then please drop a comment

Previous Post Next Post