Create a CI/CD pipeline for IoT Edge with Azure DevOps Starter

Applies to: yes icon IoT Edge 1.1 yes icon IoT Edge 1.2

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 Trial 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.

  1. Sign in to the Azure portal.

  2. In the left pane, select Create a resource, and then search for DevOps Starter.

  3. Select Create.

  4. By default, the DevOps Starter is set up with GitHub. To utilize the features in this how-to, switch the DevOps Starter to set up using Azure DevOps. Follow the change settings here link.

    Select change settings here to switch from GitHub to Azure DevOps

  5. In the right pane, choose the Azure DevOps tile, and select Done.

    Select Azure DevOps to set up your DevOps Starter

    You should now see that the DevOps Starter is setting up with Azure DevOps.

Create a new application pipeline

  1. Your Azure IoT Edge module(s) can be written in C#, Node.js, Python, C and Java. Select your preferred language to start a new application: .NET, Node.js, Python, C, or Java. Select Next to continue.

    Select language to create a new application

  2. Select Simple IoT as your application framework, and then select Next.

    Select Simple IoT framework

  3. Select IoT Edge as the Azure service that deploys your application, and then select Next.

    Select IoT Edge service

  4. Create a new free Azure DevOps organization or choose an existing organization.

    1. Provide a name for your project.

    2. Select your Azure DevOps organization. If you don't have an existing organization, select Additional settings to create a new one.

    3. Select your Azure subscription.

    4. Use the IoT Hub name generated by your project name, or provide your own.

    5. Accept the default location, or choose one close to you.

    6. Select Additional settings to configure the Azure resources that DevOps Starter creates on your behalf.

    7. Select Done to finish creating your project.

    Name and create 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.

View project in Azure portal

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.

  1. 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.

    View repository generated in Azure Repos

    Note

    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.

  2. 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.

    Open module.json file in Azure Repos

  3. 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.

  1. 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.

    View build pipelines in Azure Pipelines

  2. Open the automatically generated build pipeline and select Edit in the top right.

    Edit build pipeline

  3. 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.

  4. 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.

    Edit the pipeline details

  5. Select Save & queue, and then select Save. It is optional to comment.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

    View release pipeline

  10. Under Artifacts, select Drop. The source that this artifact watches is the output of the build pipeline you examined in the previous steps.

  11. 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.

  12. 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.

    View continuous deployment tasks

  13. On the right, select View releases. This view shows a history of releases.

  14. 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.

Next steps