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
- Use Azure Cloud Shell to create the Device Provisioning Service.
- Choose the Bash environment.
- Select Show advanced settings.
- Use the existing storage account that resides in the resource group location and the existing
cloudshell
file share name. 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.
- In the Azure Portal, navigate to the DPS created in the first objective.
- Click on Linked IoT hubs in the DPS pane.
- Click + Add and select iothub-XXXXX from the drop-down. Click Save.
- 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.
- In the Azure Portal, navigate to the DPS created in the first objective.
- Click on Manage allocation policy in the DPS pane.
- Under Select how you want to assign devices to hubs, select Lowest latency, then click Save.