fbpx

Both Azure Event Grid and Azure IoT Hub are massively scalable messaging services in the Microsoft Azure Cloud. There’s a lot of talk about Azure Event Grid; partially because it’s a new service (at this time) and because it extends the Serverless story. While Azure IoT Hub isn’t built for Serverless, it is built to scale to billions of connected IoT devices. These 2 services look different, yet similar at the same time. Which one is best to use when building out an Internet of Things (IoT) solution?

Let’s take a brief look at the features and purpose of each of these services to figure out which one is “better” for IoT.

Azure Event Grid

Azure Event Grid vs Azure IoT Hub: Which is better for IoT? 1Azure Event Grid is a massive scale messaging service built for Event-Driven architectures. This lends itself nicely to the Serverless model of computing using cloud services such as Azure Functions and Azure Logic Apps. An Event gets sent into Azure Event Grid (the messaging service) and then it gets sent out to an Event Handler or Subscriber to be handled. This is the same description of pretty much any messaging broker service, however, Azure Event Grid is built to handle a massive scale of events flowing through the service.

In the terminology of Azure Event Grid, you setup Topics on the Event Grid service that will receive Events from Event Publishers. These publishers could be any application, possibly an IoT device. Then you setup Event Subscriptions that will funnel Events out to specific Event Handlers that will perform some kind of action when the Events are received.

Azure Event Grid vs Azure IoT Hub: Which is better for IoT? 2

One of the key aspects to Azure Event Grid, in addition to it being build for massive scale, is that it is also built specifically for Serverless architectures. You could use different messaging services with Serverless architectures. Although, generally Serverless architectures need to reach high levels of scalability and this is what makes Event Grid a good match.

The example uses of Azure Event Grid that Microsoft calls out specifically are:

  • Serverless application architectures
  • Ops automation
  • Application integration

This list of example uses may seem simple, but they do encompass a very large number of enterprise scenarios. If we just look at the “Serverless application architectures”, well, that could be pretty much ANY type of application; event Internet of Things (IoT).

Azure Event Grid vs Azure IoT Hub: Which is better for IoT? 3

Looking at the main focus of Azure Event Grid, it certainly could be used to implement a solution with Internet of Things (IoT) devices that sent event telemetry to the service. Then, you could handle those events through the integration of Azure Functions or Logic Apps to provide processing and further integrations and storage.

Azure IoT Hub

Azure Event Grid vs Azure IoT Hub: Which is better for IoT? 4Azure IoT Hub is a message broker service within Microsoft Azure that, at the base level, provides massive scale messaging for integrating BILLIONS of connected Internet of Things (IoT) devices. In addition to being a message broker, it also integrates some features that are specifically tailored towards IoT.

Here are the main, key features of Azure IoT Hub:

  • Connect and manage BILLIONS of IoT devices
  • Establish reliable, two-way communication between cloud and device
  • Register, manage, and secure IoT devices individually

Azure Event Grid vs Azure IoT Hub: Which is better for IoT? 5

In addition to being a message broker that currys messages from a sender to a receiver, IoT Hub also integrates functionality to facilitate two-way message communication. There are many scenarios with IoT that requires some kind of command-and-control of the IoT devices, and the “cloud-to-device” messaging capabilities of Azure IoT Hub enable this to be implemented fairly easily. Instead of solely sending event messages from the devices into the cloud, the resulting solution is capable of also sending event messages from the cloud to the device.

Another aspect of Azure IoT Hub that makes it different than most other messaging services is that the messages aren’t sent to handlers “one-at-a-time”. Instead, the event messages are added to be part of a larger event stream within the service, then the handlers get access to the full stream of messages. This more easily enables the implementation of analytics and processing of the data stream where the handlers can traverse up and down the stream (in terms of time). This allows for data aggregates and other processing to be more easily performed on the event data flowing through the stream.

For real-time processing and analytics of the event stream, Azure Stream Analytics can be integrated to easily add this processing without the need to implement the necessary code yourself. This enables processing and analytics logic to easily be implemented and to simultaneously funnel the data out using a Lambda Architecture. Lambda Architectures enable real-time (fast) and batch (slow) processing of the same stream of event data within the same applications. It enables the benefits of being able to process and analyze the data in real-time and at a later time within the same system with fewer compromises.

Which is “better” for IoT?

The TLDR answer is, Azure IoT Hub. However, it can depend on the requirements of the system.

  1. For just sending event messages into the cloud, either Azure IoT Hub or Event Grid could be used. There are also other messaging services that could be used as well depending on the required scale of the system.
  2. For 2-way messaging (both Device-to-Cloud and Cloud-to-Device) then the only real answer is to use Azure IoT Hub. With Azure IoT Hub’s device management capabilities you can easily secure each device individually and manage it’s communications easily.
  3. For real-time processing and analytics, and the integration of Azure Stream Analytics, then you would need to use Azure IoT Hub. At the time of writing this, the Azure Event Grid service does NOT support sending events to Azure Stream Analytics, so in order to implement this the Azure IoT Hub service is the option of choice here.
  4. For individual device management and security of connected IoT devices, the only service that incorporates this functionality is Azure IoT Hub. While you can secure individual message senders with different messaging services, the Azure IoT Hub service is purpose built for managing and connection individual IoT devices in the scale of Billions of IoT devices.

While it’s alway good to compare and contrast a couple different options for implementing a solution, the answer is quite simple here. For Internet of Things (IoT) solutions, it’s generally best to use Azure IoT Hub. The service is built specifically for IoT solutions with device management and 2-way communication capabilities built into the service. Azure IoT Hub is the only messaging service within Microsoft Azure that has these extra capabilities built-in. All other messaging services are merely for sending messages to the message broker service, thus requiring you to build in the 2-way messaging architecture yourself.

Essentially, Azure IoT Hub is generally the best option for IoT solutions, unless you don’t (and will never) need any of these extra features then you could use a different messaging solution if desired. However, if you may need device management and 2-way communication later on, then it is good to start with Azure IoT Hub from the start so you’re prepared without requiring a complete re-architecture in the event that those features will be needed for your IoT solution later on.

Happy integrating cloud capabilities into your Internet of Things (IoT) solutions! Cloud enable all the things!

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect

Discover more from Build5Nines

Subscribe now to keep reading and get access to the full archive.

Continue reading