Skip to content

Azure IoT Edge Messaging

This scenario demonstrates how to deploy an IoT Edge module.

Prerequisites

Architecture

architecture

Setup

on Docker container

To run the IoT Edge runtime on a Docker container with Ubuntu 22.04, follow the steps below.

# set environment variables
export DEVICE_CONNECTION_STRING="HostName=YOUR_IOT_HUB.azure-devices.net;DeviceId=YOUR_DEVICE_ID;SharedAccessKey=YOUR_SHARED_ACCESS_KEY"

# check if the container is running
docker ps

# exec into the container
docker exec -it workshop-azure-iot-iot-edge-1 bash

in the container

# install iot edge runtime
bash install-iot-edge.sh

ref. 【ubuntu】Docker で systemctl を使えるようにする

on Azure VM

Deploy Azure VM via Azure Portal with Ubuntu 22.04. See Create a Linux virtual machine in the Azure portal for details.

# SSH into the VM
IP_ADDRESS=111.111.111.111
ssh -i ~/.ssh/id_rsa azureuser@$IP_ADDRESS

# sudo to root
sudo su

# set environment variables
export DEVICE_CONNECTION_STRING="HostName=YOUR_IOT_HUB.azure-devices.net;DeviceId=YOUR_DEVICE_ID;SharedAccessKey=YOUR_SHARED_ACCESS_KEY"

# create an install script (copy and paste install-iot-edge.sh)
cat <<EOF > install-iot-edge.sh

# install iot edge runtime
bash install-iot-edge.sh

Usage

# help
iotedge -h

# list modules
iotedge list

# monitor logs
iotedge logs SimulatedTemperatureSensor

References

Azure IoT Edge