Azure IoT Edge is a fully managed service that delivers cloud intelligence locally by deploying and running artificial intelligence (AI), Azure services, and custom logic directly on cross-platform IoT devices. An Edge solution contains one or more modules, which are hosted as docker images and run in docker container on Edge device. In order for an Edge solution to be applied to target Edge device(s), a deployment needs to be created in IoT Hub.
The Azure Iot Edge for Azure Pipelines extension is a tool for you to easily setup CI/CD pipelines on Azure DevOps. It provides Build and Push task for continuous integration and Deploy to IoT Edge devices task for continuous delivery.
- For Build and Push, you can specify which modules to build and the target container registry for the docker images
- For Deploy to IoT Edge devices, you will set IoT Hub as the target of deployment and configure other parameters (priority, target condition).
You can use Azure IoT Edge for Azure Pipelines to setup CI/CD on different platforms, amd64, windows-amd64 or arm. For amd64 and windows-amd64, Azure DevOps already provides a set of hosted agents for CI/CD (You can find more information in our official documentation).
In this thread, we will introduce CI/CD on ARM platform agent. Since Azure DevOps doesn't provide hosted ARM agent currently, we need to setup a private ARM agent.
Test on Raspberry Pi 3 (other ARM devices with Linux kernel not tested, but should be able to work)
Run Edge runtime and build agent on same device
For most of the cases, we would set build agent on an ARM device and use another ARM device as the Edge device running Edge runtime. But if you only have one ARM device, don't worry, you can setup the device for 2 roles: build agent and Edge device.
The CI/CD task will use docker command to build and push docker images. So docker is a requirement. You can refer to Get Docker CE for Debian to setup Docker-CE on ARM device.
|If your Pi is already installed with IoT Edge runtime, then the moby-based container engine is already installed. Docker CE/EE container images are compatible with the Moby-based runtime, so you can skip this step to setup Docker runtime.|
You need to install python and pip.
|The test version of python is 2.7.13, pip is 18.1. But other versions (including python3) should be able to work.|
You can follow Install Azure CLI on Linux manually to install Azure CLI. After installation complete, you can execute az –version to check if Azure CLI is successfully installed.
Setup build agent
Follow Deploy an agent on Linux to download package and set the ARM device as a build agent.
In the step Get agent, you need to select Linux and ARM
After that, you can see the new ARM agent pool with the agent pi-agent in Online state.
Prepare sample Edge solution
For quick start, you can use an existing sample solution, it is the basic Edge solution that contains only one custom module which will pipe the message from simulated temperature sensor.
|To use this sample solution, first fork it to your own repository. And then replace the file modules/SampleModule/module.json
"zhiqing.azurecr.io" with your own container registry. In the later step to set the container registry in build pipeline, use the same settings.
Setup CI/CD pipeline
Follow this guide to setup your DevOps account, and setup the CI/CD pipeline.
Regarding the source setting in CI, you need to set the source as the forked repository in the previous step.
For continuous integration (build pipeline), when setting Agent pool, you need to specify the one in the Setup build agent step.
For continuous delivery (release pipeline), it is not platform sensitive. So, you can use Hosted VS2017 or Hosted Ubuntu 1604 to do the deployment for better performance. ARM agent is also able to use.
Trigger pipeline and verify
You can manually queue a new build in build pipeline. It will build and push docker images in build pipeline, and then trigger release pipeline to deploy to IoT Hub. After CI/CD pipeline finished, you will be able to see the deployment on Azure Portal -> IoT Hub -> IoT Edge.
In Edge device details, we can see that all the 4 modules are already deployed to the target device and in running state.
You can use Azure IoT Toolkit to monitor D2C message sent by the Edge device.
Meet error ('Connection aborted.', error(13, 'Permission denied')) in build pipeline
The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. But the build task won't be executed as user root. Follow the Post-installation steps for Linux to resolve this issue.
Meet error Unable to locate executable file: 'iotedgedev' in build pipeline
The build task leverages the tool 'iotedgedev' for docker related work. In the beginning of the task, it will try to install this dependency. But under some circumstances, the installation process will fail. Please raise issue on the repo of Azure IoT Edge For Azure Pipelines. As a word around, manually install iotedgedev with this guide.
You can get started with installing the Azure IoT Edge for Azure Pipelines extension in marketplace! We would love to know your feeling or suggestions with this extension, feel free to provide your feedback via the Github repository.
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here