IoT Hub
IoT Hub is a scalable ingestion mechanism to connect millions of devices to your solution back end. As a managed service, you do not have to think about deploying and maintaining servers. Scaling the solution is a matter of selecting the correct tier and setting the amount of processing units within that tier.
The term ingestion is not entirely appropriate because IoT Hub provides reliable and secure bidirectional communication. With device-to-cloud messages, devices send messages to IoT Hub and with cloud-to-device messages your back end can send messages to devices to have them perform an action.
From a very high level, the topology is as follows:
Devices that are powerful enough to connect to Azure IoT Hub directly can do so from a selection of supported protocols. When a device cannot connect directly, it can forward data via an Azure IoT Edge solution. When I use the term Azure IoT Edge, I refer to specific Microsoft solutions that can be deployed at the edge, possibly extended with third party plug-ins.
Device messages are stored in a queue that your back end solution consumes for further processing. With declarative message routing, IoT Hub makes it easy to forward messages to other services based on a query. You can, for instance, send specific alert messages from a device to a Service Bus Queue or Topic. Before this feature existed, you had to write custom code to achieve this.
When you connect many devices to IoT Hub, it helps to know more about these devices such as their location or version. Instead of storing this information in a custom database, IoT Hub provides a queryable store for device metadata. Since devices are known in advance, security keys or X.509 certificates can be stored to enable secure communications from devices.
Microsoft provides several IoT SDKs. The device SDKs contain code to build software for devices and applications to connect to Azure IoT Hub. The SDKs support the following languages:
- C
- Python
- Node.js
- Java
- .NET
Besides supporting the above languages, Microsoft also maintains an Azure Certified for IoT device catalog. The catalog does not contain Particle devices though you will find support for Arduino, Raspberry Pi and devices with industry certification. The catalog provides many search options such as connectivity type (Bluetooth, LAN, WIFI, ...) or cloud protocol (AMQPS, MQTT, ...). The device we will use is a MKR1000, which is a supported device.
In the next sections, we will explore the features of IoT Hub step by step with practical examples. If you do not have an IoT Hub anymore, recall the commands from the first chapter:
az group create --name <resource_group_name> --location westeurope
az iot hub create --sku F1 --name <IoT_Hub_Name> --resource-group <resource_group_name>
Note that this creates a free IoT Hub and that you are limited to one free IoT Hub per subscription.