How-To: Azure IoT Edge - Installation

#iotedge #azure #cloud #linux #iot #how-to #microsoft

Azure IoT Edge is an open source edge runtime framework which lets you easily deploy, manage and scale your IoT edge environment using the Azure Cloud. In this tutorial I will show you how to install Azure IoT Edge on Linux.

Introduction

Before we can get started we will have to know that Azure IoT Edge is combined of three main components:

  • IoT Edge modules which contain locally available services, applications or other business related logic which are managed by the
  • IoT Edge runtime which runs locally and manages or orchestrates the deployed modules. It is remotely monitored and managed by the
  • Azure IoT Edge Cloud Interface available with any free or standard tier Azure IoT Hub.

In this tutorial we will install the second component from above, the Azure IoT Edge runtime on Ubuntu Server 20.04.4 LTS.
A fresh, unmodifed installation should work. Get Ubuntu Server 20.04.4 LTS here. For more information on how to install Ubuntu Server please see here.

Azure IoT Edge can only be used with the free or standard tiers of the Azure IoT Hub, not using the basic tier. For more information about the basic and standard tiers, see the corresponding Microsoft documentation "How to choose the right IoT Hub tier".

Installing Azure IoT Edge package repository

First, we will need to install the package repository for APT from Microsoft. This is done using the below commands:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

Installing the moby container runtime

As Azure IoT Edge modules are packaged into OCI-compatible containers, we will need to install a supported container engine. Currently the only compatible runtime is moby. Dont worry, you can still build your container images using docker. Docker images are compatible with moby.

sudo apt-get update
sudo apt-get install moby-engine

Deploying Azure IoT Edge to production environments is a lot more complex than the below configuration. The below configuration is in no way recommended for production use! See the article "Prepare to deploy your IoT Edge solution in production" of the official microsoft documentation on how to prepare your IoT Edge solution for production use.

After the moby container runtime is installed we need to configure it to use the local logging driver. This is done by editing the container runtime configuration file, which is the same as with docker. To do this, open the file /etc/docker/daemon.json with your favourite text editor:

nano /etc/docker/daemon.json

Then, change the logging driver to "local" as below:

{
   "log-driver": "local"
}

Installing the IoT Edge runtime

Once the moby container runtime is installed, we can proceed to install all services related to the IoT Edge runtime. The below commands will install two packages, first the "aziot-edge" package, which is the IoT Edge service. This will manage all the modules and services on your device, according to the configuration provided by the cloud services. The second package is the "defender-iot-micro-agent-edge" package. It was first introduced with IoT Edge version 1.2 and is responsible for managing the identities for all services which will need to connect with the Azure IoT Hub. To install both packages, run the below commands:

sudo apt-get update
sudo apt-get install aziot-edge defender-iot-micro-agent-edge

To learn more about the new Microsoft Defender for IoT (formerly Azure Defender for IoT) please refer to the corresponding Microsoft documentation article "What is Microsoft Defender for IoT for device builders?".

Next steps

If everything went well, you will now have a successful installation of the Azure IoT Edge runtime. Next up is "Provisioning Azure IoT Edge devices to your Azure IoT Hub"

About

Hey, nice to finally meet you! My name is Maximilian, welcome to my blog!