So, it is time to dive into this protocol by running an MQTT broker on the edge and consuming it:
Yes, we are going to deploy a regular MQTT broker as a docker container within Azure IoT Edge (which uses Moby under the covers). Then, we bridge messages sent to MQTT topics to the cloud using Azure IoT Hub.
For this exercise, I have chosen HiveMQ as a broker.
Most of you Azure IoT developers are connecting devices to the Azure cloud using the Azure IoT Device SDKs.
Using these SDKs, you can connect a device to the cloud in an easy and secure way with your favorite programming language like C#, C, Java, Python, or Node.js.
This is the recommended way because it offers a convenient and optimized way to support all Azure IoT Hub features like Device Twin, Direct methods, and Cloud messages. It takes away a lot of the code wiring and you can focus on functionality.
Still, in a few instances, like working with very constrained devices, there could be a need for bare MQTT support:
MQTT is the de-facto standard for stateful communication in the IoT World (btw. Bare AMQP is offered too).
Let’s see how the Azure IoT Hub supports bare MQTT.