Azure Event Grid in a Nutshell

Alberto De Natale
4 min readJun 29, 2019

--

Azure Event Grid is a product that allows the developer to create event-based solutions.

It is important to distinguish between event-based solution from message-based solution and that goes to understand the difference between a message and an event.

Events are:

  • Actionable, the publisher does not have expectations on how the event is handled and the consumer decides what to with it
  • Lightweight, they carry information about what happened but no data of what triggered the event
  • If part of a series they are analyzable, time-ordered and interrelated

For more information see:

Main Concepts

They are:

  • Events — What happened
  • Event sources — Where the event took place
  • Topics — An endpoint where a published send events
  • Event subscriptions — An endpoint to route events and filter incoming events
  • Event handlers — App or service reacting to the event

Usages

There are mainly three usages of Azure Event Grid

  • DevOps, it allows azure handlers to react to events triggered by the Azure portal itself when for instance a new virtual machine gets created
  • Serverless, when used to trigger Azure Functions
  • Integration, when used to connect different products running in an enterprise. For instance, when connecting different products like an HR application with a mailing provider, the two may communicate using Azure Event Grid

Create An Azure Event Grid Topic

I will try to create an Azure Event Grid Topic named, hello world:

If you are interested in “Cloud Event Schema” see:

Here is the page that opens after the creation:

Create a WebHook subscription

I will create an Azure Function that will provide a WebHook subscription using the default template that comes shipped with Visual Studio:

Debugging a locally running Azure Function may be done as described in:

After deployment, I will be able to create a subscription for it:

I will have first to set some generic properties:

Followed by the references to the created topic:

The webhook details will be automatically populated:

Add an Event to the Topic

I will take the code that I found here and I will use it to post an event to the topic:

I will download the following Nuget Package:

I found the topic URL in here:

Picked the topic access key from

Once run, the function correctly receives the event:

Conclusions

Azure event grid is a powerful and flexible tool that easy the integration between different solutions.

--

--

Alberto De Natale
Alberto De Natale

Written by Alberto De Natale

Alberto De Natale is a passionate tech-enthusiast software developer.

No responses yet