| title | Continuous integration and continuous deployment to Azure IoT Edge devices |
|---|---|
| description | Set up continuous integration and continuous deployment using YAML - Azure IoT Edge with Azure DevOps, Azure Pipelines |
| author | sethmanheim |
| ms.author | sethm |
| ms.date | 05/08/2025 |
| ms.topic | concept-article |
| ms.service | azure-iot-edge |
| services | iot-edge |
[!INCLUDE iot-edge-version-all-supported]
Adopt DevOps with Azure IoT Edge applications using the built-in Azure IoT Edge tasks in Azure Pipelines. This article shows how to use Azure Pipelines to build, test, and deploy Azure IoT Edge modules using YAML.
:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/model.png" alt-text="Diagram of continuous integration and continuous development branches for development and production.":::
In this article, you learn how to use the built-in Azure IoT Edge tasks for Azure Pipelines to create build and release pipelines for your IoT Edge solution. Each Azure IoT Edge task in the pipeline performs one of the following actions:
| Action | Description |
|---|---|
| Build module images | Takes your IoT Edge solution code and builds the container images. |
| Push module images | Pushes module images to the container registry you specified. |
| Generate deployment manifest | Takes a deployment.template.json file and the variables, then generates the final IoT Edge deployment manifest file. |
| Deploy to IoT Edge devices | Creates IoT Edge deployments to one or more IoT Edge devices. |
Unless specified, this article doesn't cover all the functionality available through task parameters. For more information, see the following resources:
-
An Azure Repos repository. If you don't have one, Create a new Git repo in your project. For this article, the repository is called IoTEdgeRepo.
-
An IoT Edge solution committed and pushed to your repository. To create a new sample solution for testing this article, follow the steps in Develop Azure IoT Edge modules using Visual Studio Code. For this article, we created a solution in our repository called IoTEdgeSolution, which has the code for a module named filtermodule.
For this article, all you need is the solution folder created by the IoT Edge templates in either Visual Studio Code or Visual Studio. You don't need to build, push, deploy, or debug this code before proceeding. You set up those processes in Azure Pipelines.
Make sure you know the path to the deployment.template.json file in your solution, which is used in several steps. If you're unfamiliar with the role of the deployment template, see Learn how to deploy modules and establish routes.
[!TIP] If you're creating a new solution, clone your repository locally first. Then, when you create the solution you can choose to create it directly in the repository folder. You can easily commit and push the new files from there.
-
A container registry where you can push module images. You can use Azure Container Registry or a third-party registry.
-
An active Azure IoT hub with at least two IoT Edge devices for testing the separate test and production deployment stages. Follow the quickstart articles to create an IoT Edge device on Linux or Windows.
Learn more about using Azure Repos in Share your code with Visual Studio and Azure Repos.
In this section, you create a new build pipeline. You configure the pipeline to run automatically when you check in any changes to the sample IoT Edge solution and to publish build logs.
-
Sign in to your Azure DevOps organization (
https://dev.azure.com/{your organization}), and open the project that contains your IoT Edge solution repository.:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/initial-project.png" alt-text="Screenshot showing how to open your DevOps project.":::
-
From the left pane menu in your project, select Pipelines. Select Create Pipeline at the center of the page. Or, if you already have build pipelines, select the New pipeline button in the top right.
:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/add-new-pipeline.png" alt-text="Screenshot showing how to create a new build pipeline using the New pipeline button .":::
-
On the Where is your code? page, select Azure Repos Git
YAML. -
Select the repository you are creating a pipeline for.
:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/select-repository.png" alt-text="Screenshot showing how to select the repository for your build pipeline.":::
-
On the Configure your pipeline page, select Starter pipeline. If you have a preexisting Azure Pipelines YAML file you wish to use to create this pipeline, you can select Existing Azure Pipelines YAML file and provide the branch and path in the repository to the file.
-
On the Review your pipeline YAML page, you can select the default name
azure-pipelines.ymlto rename your pipeline's configuration file.Select Show assistant to open the Tasks palette.
:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/show-assistant.png" alt-text="Screenshot that shows how to select Show assistant to open Tasks palette.":::
-
To add a task, place your cursor at the end of the YAML or wherever you want the instructions for your task to be added. Search for and select Azure IoT Edge, fill out the task's parameters as follows, and then select Add.
Parameter Description Action Select Build module images. .template.json file Provide the path to the deployment.template.json file in the repository that contains your IoT Edge solution. Default platform Select the appropriate operating system for your modules based on your targeted IoT Edge device. For more information about this task and its parameters, see Azure IoT Edge task.
:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/add-build-task.png" alt-text="Screenshot of the Use Tasks palette and how to add tasks to your pipeline.":::
[!TIP] After each task is added, the editor will automatically highlight the added lines. To prevent accidental overwriting, deselect the lines and provide a new space for your next task before adding additional tasks.
-
Repeat this process to add three more tasks with the following parameters:
-
Task: Azure IoT Edge
Parameter Description Action Select Push module images. Container registry type Use the default type: Azure Container Registry. Azure subscription Select your subscription. Azure Container Registry Choose the registry that you want to use for the pipeline. .template.json file Provide the path to the deployment.template.json file in the repository that contains your IoT Edge solution. Default platform Select the appropriate operating system for your modules based on your targeted IoT Edge device. For more information about this task and its parameters, see Azure IoT Edge task.
-
Task: Copy Files
Parameter Description Source Folder The source folder to copy from. Empty is the root of the repo. Use variables if files are not in the repo. Example: $(agent.builddirectory).Contents Add two lines: deployment.template.jsonandmodules/**/module.json.Target Folder Specify the variable $(Build.ArtifactStagingDirectory). See Build variables to learn about the description.For more information about this task and its parameters, see Copy files task.
-
Task: Publish Build Artifacts
Parameter Description Path to publish Specify the variable $(Build.ArtifactStagingDirectory). See Build variables to learn about the description.Artifact name Specify the default name: dropArtifact publish location Use the default location: Azure PipelinesFor more information about this task and its parameters, see Publish build artifacts task.
-
-
Select Save from the Save and run dropdown in the top right.
-
The trigger for continuous integration is enabled by default for your YAML pipeline. If you want to edit these settings, select your pipeline, and select Edit in the top right. Select More actions next to the Run button in the top right, and go to Triggers. Continuous integration shows as enabled under your pipeline's name. If you want to see the details for the trigger, check the Override the YAML continuous integration trigger from here box.
:::image type="content" source="./media/how-to-continuous-integration-continuous-deployment/check-trigger-settings.png" alt-text="Screenshot showing how to review your pipeline's trigger settings from the Triggers menu under More actions.":::
Continue to the next section to build the release pipeline.
[!INCLUDE iot-edge-create-release-pipeline-for-continuous-deployment]
[!INCLUDE iot-edge-verify-iot-edge-continuous-integration-continuous-deployment]
- Understand the IoT Edge deployment in Understand IoT Edge deployments for single devices or at scale
- Walk through the steps to create, update, or delete a deployment in Deploy and monitor IoT Edge modules at scale.
