0 Comments

Following is a guidance how to set up Raspberry PI from the scratch to working Azure IoT Edge device.

There is a three step-by-step articles.

Lets do it together step-by-step.

The Azure IoT Edge runtime is what turns a device into an IoT Edge device. The runtime can be deployed on devices as small as a Raspberry Pi or as large as an industrial server. Once a device is configured with the IoT Edge runtime, you can start deploying business logic to it from the cloud.

Step 0. Login to your Raspberry

Before any further step you have to log in to your Raspberry.

  1. Open PuTTY
  2. Enter your Raspberry name and connect
  3. Log in using username: pi and password: raspberry (if not changed)

Step 1. Install the latest runtime version

1. Prepare your device for the IoT Edge runtime installation.

curl https://packages.microsoft.com/config/debian/stretch/multiarch/prod.list > ./microsoft-prod.list

2. Copy the generated list.

sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/

3. Install Microsoft GPG public key.

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/


Step 2. Install the container runtime

Azure IoT Edge relies on an OCI-compatible container runtime. Microsoft recommended to use the Moby-based engine provided below. It is the only container engine officially supported with Azure IoT Edge.

1. Perform apt update.

sudo apt-get update

2. Install the Moby engine.

sudo apt-get install moby-engine

3. Install the Moby command-line interface (CLI).

sudo apt-get install moby-cli


Step 3. Install the Azure IoT Edge Security Daemon

The IoT Edge security daemon provides and maintains security standards on the IoT Edge device. The daemon starts on every boot and bootstraps the device by starting the rest of the IoT Edge runtime.

1. Perform apt update.

sudo apt-get update

2. Install the security daemon.

sudo apt-get install iotedge


Step  4. Configure the security daemon

To manually provision a device, you need to provide it with a device connection string that you can create by registering a new device in your IoT hub.

Before you can configure security daemon in your IoT Edge device, you have to register your new in Azure IoT Hub.

Please take a look the third article on this series and then come back here to register your device.

#3 Registering the deviceas an IoT Edge device in Azure.

Do you have already IoT hub and Edge device in Azure?

If you have already your IoT Edge device created in Azure IoT hub, then just copy the device connection string from the Azure portal and you can immediately configure your Raspberry.

Based this connection string the device knows where is the cloud and cloud knows how to find and connect with the device.

  1. Open PuTTY and connect to your device
  2. Enter following command to open configuration file config.yaml
sudo nano /etc/iotedge/config.yaml

3. Find Manual provisioning section

Find the provisioning configurations of the file and uncomment the Manual provisioning configuration section.

4. Update the value of device_connection_string

Update the value of device_connection_string with the connection string from your IoT Edge device. Make sure any other provisioning sections are commented out.

# Manual provisioning configuration provisioning:
	source: "manual"
	device_connection_string: "HostName=IoTHubForTestingPurposes.azure-devices.net;DeviceId=TestDevice;SharedAccessKey=manynumbersandletters"
# DPS TPM provisioning configuration

5. Save and close the file, CTRL + X, Y, Enter.

  • Close the file: Ctrl + X
  • Do you want to save: Y
  • Exit: Enter

6. Restart your device IoT Edge daemon

sudo systemctl restart iotedge

Congratulation: you have now a working Azure IoT Edge device!

We can start to develop solutions on it but there are some tricky things so I will publish additional guidance's for tips and tricks.

Post comment