Working with the Azure IoT Device Provisioning Service

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

The Device Provisioning Service allows you to deploy thousands of devices without human interaction. In this lab, we will work the the DPS and integrate it into our Azure IoT solution.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the Azure Device Provisioning Service
  1. Use Azure Cloud Shell to create the Device Provisioning Service.
  2. Choose the Bash environment.
  3. Select Show advanced settings.
  4. Use the existing storage account that resides in the resource group location and the existing cloudshell file share name.
  5. Once in the shell, enter the following to create the IoT hub:

     az iot dps create --name IoTDPS-XXXXX --resource-group <TAB> --location westus

    XXXXX is the five-character suffix for the lab resources and <TAB> is the Tab key. Press it there to automatically populate the resource group name.

Create Shared Access Policies in the IoT Hubs

While many tutorials state that the DPS can use the iothubowner shared access policy to link to an IoT Hub, best practice is to configure a new shared access policy with only the permissions required to link the Hub.

In the Azure Portal, navigate to iothub-XXXXX (where XXXXX is the five-character suffix for the lab resources) and create a new shared access policy by clicking on Shared access policy, then + Add. Create the policy with the name dps and set the following permissions:

  • Registry read
  • Registry write
  • Service connect

Repeat this procedure for iothub2-XXXXX.

Link the IoT Hubs to the DPS

In order to assign devices to IoT Hubs, they must be linked to the DPS.

  1. In the Azure Portal, navigate to the DPS created in the first objective.
  2. Click on Linked IoT hubs in the DPS pane.
  3. Click + Add and select iothub-XXXXX from the drop-down. Click Save.
  4. Repeat step 3 for iothub2-XXXXX.
Configure the DPS Allocation Policy

Our final requirement is to configure the DPS to assign devices to the IoT Hubs based on lowest latency.

  1. In the Azure Portal, navigate to the DPS created in the first objective.
  2. Click on Manage allocation policy in the DPS pane.
  3. Under Select how you want to assign devices to hubs, select Lowest latency, then click Save.

Additional Resources

You have recently been hired by Parktronics, a monitoring company that works with local, state, and national park services. They have decided to use Azure IoT to develop Gatekeeper, a solution that will monitor entry and exit gates to ensure they are closed and locked at closing time.

You've been tasked with creating a proof-of-concept of the Gatekeeper solution. Part of the solution must include a way to automatically provision IoT devices in the field.

You will need to:

  • Create an Azure Device Provisioning Service using the CLI.
  • Link two pre-provisioned IoT Hubs to the DPS.
  • Configure the DPS to assign devices based on lowest latency.

If you get stuck, feel free to check out the solution video or the detailed instructions under each objective. Good luck!


You will be using the Azure CLI to perform most of the tasks in this lab. You can access the CLI by using Azure Cloud Shell. When accessing the shell, select Show advanced settings, and use the existing storage account that resides in the location where the storage group is.

We will be using the Raspberry Pi Azure IoT Online Simulator as our device in this lab. You can access the simulator at

Lab Suffix

Pre-deployed lab resources will all end with a unique five-character suffix. Make note of this suffix, as you may need it when naming resources during the lab.

WARNING: Be Prepared for UI Changes

Given the fluid nature of Microsoft cloud tools, you may experience user interface (UI) changes that were made following the development of this hands-on lab that do not match up with lab instructions. When any such changes are brought to our attention, we will attempt to update the content accordingly. However, if changes occur, students will have to adapt to the changes and work through them in the hands-on labs as needed.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?