The official documentation is very verbose and wordy, which is exactly how it should be, but this tutorial tries a more brief approach towards installing the IOT Runtime on the Raspberry Pi
Prerequisites
- You are fairly comfortable with Cloud Service providers, AWS, Azure or GCP.
- You have worked with the Raspberry Pi and SSH before
You will learn
- How to setup Azure IOT Edge using the Portal
- How to get a Raspberry Pi communicating with Azure
Key Concepts
Here are some of these explained in laymen's terms
Azure IOT Hub
Managed service to enable bi-directional communication between IoT devices and Azure
Azure IoT Hub provides a cloud-hosted solution backend to connect virtually any device.
Azure IOT Edge Device
- Logical representation, or the identity which the IOT Hub assigns every physical hardware device connected to it.
Azure IOT Runtime
- Enables custom and cloud logic on IoT Edge devices. The runtime sits on the IoT Edge device, and performs management and communication operations.
1. Setting up Azure
Creating the Hub
- Login to the Azure Portal
- Search for 'IOT Hub'
- Click Add, under Size and Scale select Free Tier, accept the defaults and create an IOT Hub
Creating the Edge Device
- Go to the IOT Hub you just created
- From the side panel under Automatic Device Management, click IoT Edge, then click New
- Add a device name, accept the defaults and click Save
- Refresh, click the Device you just created, unhide and copy the Primary Connection String, keep this handy for later.
References - Quickstart: Deploy your first IoT Edge module to a virtual Linux device
2. Setting up the Raspberry Pi
Prerequisites
- Ensure that the Raspberry Pi (RPi) is running Raspbian Stretch
- Ensure that Docker and Docker Compose are installed. Read More - Installing Docker and Docker Compose on the Raspberry Pi in 5 Simple Steps
Installing Azure IOT Edge Runtime
1) Registering Microsoft key and software repository feed
curl https://packages.microsoft.com/config/debian/stretch/multiarch/prod.list > ./microsoft-prod.list
sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/
2) Installing Moby-Engine, and IOTEdge Runtime
sudo apt-get update -y
sudo apt-get install libssl1.0.2 moby-engine moby-cli iotedge -y
3) Let's add the connection string to connect the RPi with Azure
sudo nano /etc/iotedge/config.yaml
Add the Primary Connection String from Step 1.2 in here, and it should look something like this.
# Manual provisioning configuration
provisioning:
source: "manual"
device_connection_string: "HostName=XXX.azure-devices.net;DeviceId=rpi-1;SharedAccessKey=XXXXc="
4) Setup is done, restart the service.
sudo systemctl restart iotedge
5) Verify the installation.
sudo systemctl status iotedge
sudo iotedge check # should return 1 check as failed 'Edge Hub can bind to ports on host'
sudo iotedge list # No modules are running
References - Install the Azure IoT Edge runtime on Debian-based Linux systems
In the next tutorial, we will Deploy a Module to Azure IOT Edge Runtime on Linux
Note
I know It's frustrating when something works in the tutorial but not when you do it, I would hate if that happened to you. So, please leave a comment, or reach out to me. If any of this does not work for you.
Top comments (1)
Hi, I've got a problem.
"Could not sart module edgeAgent caused by: OCI runtime create failed: container with id exists". This appear after "sudo systemctl status iotedge" command.
"sudo iotedge check" returned: "config.yaml has correct URIs for daemon mgmt endpoint - Error. Docker: Error response from daemon: csgroups: cgroup mountpoint does not exist: unknown."
"sudo iotedge list" returned: Status: stopped.
Can you help me?