One of my favorite things about cloud services in general and Azure (my world) in particular is the wealth of options for quickly creating message based architectures. In Azure we can use Service Bus, Event Hubs, Event Grid, and more to manage our messages and easily consume them using our traditional sorts of applications or easy to use services like Azure Logic Apps or Azure Functions.

This all makes for a great cloud side architecture, but what about getting data from a host of sensors or other devices that aren’t what we’d consider traditional computers? You know, that whole Internet of Things use case? With the power available to us in even tiny devices, connecting using our typical communication protocols is quite feasible. We can largely treat our devices like any other server-server communication and be done with it.

So why does Microsoft offer a whole suite of IoT services in Azure? Particularly [Azure IoT Hub](https://azure.microsoft.com/en-us/services/iot-hub/? I can stream large volumes of data over Event Hubs, isn’t IoT Hub redundant? Anything that can receive messages from Event Hubs can also receive messages from IoT Hub, so you can use IoT Hub as a data source for your cloud services in the same way. Thus the answer initially seems to be that yes, IoT Hub is very redundant. Why would MS build a service that does exactly the same thing?

If you only ever need to stream data from fixed sensors in a fixed location, then yes, you can probably just use Event Hubs. But that’s all Event Hubs can do. When you’re managing a bunch of devices that are not exactly traditional computers and further may be used in very out of the way places, a number of considerations come up.

Management

IoT Hub gives us the ability to manage our devices remotely. With IoT Hub, we have facilities to:

  1. Reboot the device.
  2. Send software updates to the device.
  3. Update the device configuration.

These are enabled by cloud to device messages, direct messages and the wonderful notion of Device Twins. The ability to remotely trigger updates will save someone physically visiting the device, enabling you to update large numbers of devices easily. See more on concepts in device management.

Security

As much as we may or may not like to deal with it, securing these little devices takes some effort. If you have to contend with the most important topic all on your own, that’s other features your applications don’t have. Rolling your own security is almost always a bad idea. Microsoft has invested a ton into this so you don’t have to. IoT Hub makes managing security per device much more easy than any thing you can create.

Further, we do need to think about those cases where a device goes missing or is stolen. Because each device is registered independently and uses its own authentication, disabling a device in IoT Hub is trivial.

Intermittent Connectivity

Managing devices is complicated by the reality of radio communications. Whether WiFi, Cell, Satellite, or other form of communication, once the wire is cut, reliability drops. A sensor in a vehicle is going to pass in and out of communication coverage regularly. By supporting durable communication from cloud to device, IoT Hub helps ensure that if the device is out of contact, messages can still be delivered to it when it comes back online.

Multiple Communication Pathways

IoT Hub offers more than one way to move data between the device and the cloud and back again.

From the device, IoT Hub has a native mechanism for file transfer when you need to move large amounts of data from the device. Metadata can be sent via the Device Twin’s Reported Properties. Of course, you can use Event Hubs style communication to stream data as well.

From the cloud to the device, you can send messages to your devices using Cloud to Device messaging, ensuring durable delivery. If the device is offline, IoT Hub will hold the message up to 48 hours. If you need higher speed connections for direct remote control with a more synchronous model, you can also use Direct Methods. Metadata can also be reported using the Desired Properties section of the Device Twin. These are ultra durable, only being removed if you take action to remove them.

Conclusion

If you’re managing a large number of devices, IoT Hub offers the communications you need. Without an off the shelf framework and service like IoT Hub, you would need to build and debug a wide array of functionality. Security, updates, and unreliable communications are all requirements that take significant work to implement yourself, these are easily handled with IoT Hub as most or all of the work is done for you. No one gets points for reinventing the wheel, so use the right tool for the job.