Create a CI/CD pipeline for IoT Edge with Azure DevOps Starter
Configure continuous integration (CI) and continuous delivery (CD) for your IoT Edge application with DevOps Projects. DevOps Starter simplifies the initial configuration of a build and release pipeline in Azure Pipelines.
If you don't have an active Azure subscription, create a free account before you begin.
Sign in to the Azure portal
DevOps Starter creates a CI/CD pipeline in Azure DevOps. You can create a new Azure DevOps organization or use an existing organization. DevOps Starter also creates Azure resources in the Azure subscription of your choice.
Sign in to the Microsoft Azure portal.
In the left pane, select Create a resource, and then search for DevOps Starter.
Create a new application pipeline
Select Simple IoT as your application framework, and then select Next.
Select IoT Edge as the Azure service that deploys your application, and then select Next.
Create a new free Azure DevOps organization or choose an existing organization.
Provide a name for your project.
Select your Azure DevOps organization. If you don't have an existing organization, select Additional settings to create a new one.
Select your Azure subscription.
Use the IoT Hub name generated by your project name, or provide your own.
Accept the default location, or choose one close to you.
Select Additional settings to configure the Azure resources that DevOps Starter creates on your behalf.
Select Done to finish creating your project.
After a few minutes, the DevOps Starter dashboard is displayed in the Azure portal. Select your project name to see the progress. You may need to refresh the page. A sample IoT Edge application is set up in a repository in your Azure DevOps organization, a build is executed, and your application is deployed to the IoT Edge device. This dashboard provides visibility into your code repository, the CI/CD pipeline, and your application in Azure.
Commit code changes and execute CI/CD
DevOps Starter created a Git repository for your project in Azure Repos. In this section, you view the repository and make code changes to your application.
To navigate to the repo created for your project, select Repositories in the menu of your project dashboard. This link opens a browser tab and the Azure DevOps repository for your new project.
The following steps walk through using the web browser to make code changes. If you want to clone your repository locally instead, select Clone from the top right of the window. Use the provided URL to clone your Git repository in Visual Studio Code or your preferred development tool.
The repository already contains code for a module called FilterModule based on the application language that you chose in the creation process. Open the modules/FilterModule/module.json file.
Notice that this file uses Azure DevOps build variables in the version parameter. This configuration ensures that a new version of the module will be created every time a new build runs.
Examine the CI/CD pipeline
In the previous sections, Azure DevOps Starter automatically configured a full CI/CD pipeline for your IoT Edge application. Now, explore and customize the pipeline as needed. Use the following steps to familiarize yourself with the Azure DevOps build and release pipelines.
To view the build pipelines in your DevOps project, select Build Pipelines in the menu of your project dashboard. This link opens a browser tab and the Azure DevOps build pipeline for your new project.
Open the automatically generated build pipeline and select Edit in the top right.
In the panel that opens, you can examine the tasks that occur when your build pipeline runs. The build pipeline performs various tasks, such as fetching sources from the Git repository, building IoT Edge module images, pushing IoT Edge modules to a container registry, and publishing outputs that are used for deployments. To learn more about Azure IoT Edge tasks in Azure DevOps, see Configure Azure Pipelines for continuous integration.
Select the Pipeline header at the top of the build pipeline to open the pipeline details. Change the name of your build pipeline to something more descriptive.
Select Save & queue, and then select Save. It is optional to comment.
Select Triggers from the build pipeline menu. DevOps Starter automatically created a CI trigger, and every commit to the repository starts a new build. You can optionally choose to include or exclude branches from the CI process.
Select Retention. Follow the link to redirect you to the project settings, where the retention policies are located. Depending on your scenario, you can specify policies to keep or remove a certain number of builds.
Select History. The history panel contains an audit trail of recent changes to the build. Azure Pipelines keeps track of any changes that are made to the build pipeline, and it allows you to compare versions.
When you're done exploring the build pipeline, navigate to the corresponding release pipeline. Select Releases under Pipelines, then select Edit to view the pipeline details.
Under Artifacts, select Drop. The source that this artifact watches is the output of the build pipeline you examined in the previous steps.
Next to the Drop icon, select the Continuous deployment trigger that looks like a lightning bolt. This release pipeline has enabled the trigger, which runs a deployment every time there is a new build artifact available. Optionally, you can disable the trigger so that your deployments require manual execution.
In the menu for your release pipeline, select Tasks then choose the dev stage from the dropdown list. DevOps Projects created a release stage for you that creates an IoT hub, creates an IoT Edge device in that hub, deploys the sample module from the build pipeline, and provisions a virtual machine to run as your IoT Edge device. To learn more about Azure IoT Edge tasks for CD, see Configure Azure Pipelines for continuous deployment.
On the right, select View releases. This view shows a history of releases.
Select the name of a release to view more information about it.
Clean up resources
You can delete Azure App Service and other related resources that you created when you don't need them anymore. Use the Delete functionality on the DevOps Starter dashboard.
- Learn about the Tasks for Azure IoT Edge on Azure DevOps in Continuous integration and continuous deployment to Azure IoT Edge
- 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.