Intro into Azure IoT Hub
We often get questions how Synpse is compared or competes with Azure IoT Hub service. The short answer is that they operate in slightly different domains. Azure IoT hub focuses on application connectivity of the devices while Synpse targets deployment of the applications that may or may not be using services such as IoT Core.
The best results are achieved when solutions are used together. For example, when you build an application locally that utilizes AWS IoT Core message broker or device state services and then use Synpse to distribute your application to thousands of devices.
Example application
In this tutorial, we will deploy a simple open-source application that collects metrics and send them to AWS IoT Core for further processing. All code for this blog post can be found at:
https://github.com/synpse-hq/metrics-nats-example-app - Sample metrics application https://github.com/synpse-hq/azure-iot-hub-example - Azure IoT Hub example
Steps:
- Create Azure IoT hub
- Configure rules to forward results into Azure blob storage
- Create Azure “Thing”/IoT device for Synpse
- Demo Synpse application from 3 microservices - Metrics demo, NATs messaging, Azure IoT python forwarder containers
Technologies used
- Synpse - manage devices and deploy applications to them
- NATs - a lightweight message broker that can run on-prem
- Azure IoT Hub - message broker between all devices and Azure
Contrary to AWS, Azure was easy to configure using CLI. All steps here will be done using Azure CLI.
Azure IoT Hub
- Create Azure IoT hub:
|
|
- Create certificate based on Azure documentation.
Upload the certificates for Azure device by creating “device-identity”
|
|
For this example, we gonna create a message route to the storage account blob.
- Create storage account:
|
|
- Create container/bucket for results:
|
|
- Create IoT hub endpoint for message routing:
|
|
- Use routing in question with our HUB (endpoint name is same as –endpoint-name)
|
|
Deploy an application
Deploy an application. Modify application YAML with your thing endpoint.
- Create certificate secrets
|
|
Deploy the application. You will need to modify other values inside YAML file.
|
|
where synpse-azure-example.yaml
is
|
|
You should see messages coming into the Azure IoT Hub
Once running, you should see the application running and data coming into Azure storage account blob.
Things to look for
Certificate configuration path is painful. But this is the common pattern between cloud offering. Azure offers shared private key authentication. This makes multiple device provisioning easier. If you are not interested in cloud portability - this might be easier way to deal with complexities.
Events lands into storage account without visibility how and default data structure is not possible to adjust easily. Sometimes it takes few minutes, sometimes multiple minutes. We assume this is due to ETL (Extract, Transform, Load) process, not visible to users.
Overall Azure experience was quite pleasant. API and CLI consistent, documentation is quite well written.
./wrap_up.sh
This is simple way to use Azure IoT Hub with Synpse. When it comes to consuming and managing a lot of data, constructing complex applications and integrating seamlessly into your current technological infrastructure - nothing can beat public cloud. But where cloud are lacking is - IoT device and application management.
Public cloud providers are built on assumption that they will manage infrastructure for you. When it comes to devices itself - they are yours and yours only. And this is where Public cloud providers lacks of influence and where Synpse comes into the picture.
If you have any questions or suggestions, feel free to start a new discussion in our forum or drop us a line on Discord