Configure cloud resources for device provisioning with the IoT Hub Device Provisioning Service

This tutorial shows how to set up the cloud for automatic device provisioning using the IoT Hub Device Provisioning Service. In this tutorial, you learn how to:

  • Use the Azure portal to create an IoT Hub Device Provisioning Service and get the ID scope
  • Create an IoT hub
  • Link the IoT hub to the Device Provisioning Service
  • Set the allocation policy on the Device Provisioning Service

If you don't have an Azure subscription, create a free account before you begin.

Sign in to the Azure portal

Sign in to the Azure portal.

Create a Device Provisioning Service instance and get the ID scope

Follow these steps to create a new Device Provisioning Service instance.

  1. In the upper left-hand corner of the Azure portal, click Create a resource.
  2. In the Search box, type device provisioning.
  3. Click IoT Hub Device Provisioning Service.
  4. Fill out the IoT Hub Device Provisioning Service form with the following information:

    Setting       Suggested value Description 
    Name Any unique name --
    Subscription Your subscription For details about your subscriptions, see Subscriptions.
    Resource group myResourceGroup For valid resource group names, see Naming rules and restrictions.
    Location Any valid location For information about regions, see Azure Regions.

    Enter basic information about your Device Provisioning service in the portal

  5. Click Create. After a few moments, the Device Provisioning Service instance is created and the Overview page is displayed.

  6. On the Overview page for the new service instance, copy the value for the ID scope for use later. That value is used to identify registration IDs, and provides a guarantee that the registration ID is unique.
  7. Also, copy the Service endpoint value for later use.

Create an IoT hub

Create an IoT hub for your simulated device app to connect to. The following steps show you how to complete this task by using the Azure portal.

  1. Sign in to the Azure portal.

  2. Select Create a resource > Internet of Things > IoT Hub.

    Azure portal Jumpbar

  3. In the IoT hub pane, enter the following information for your IoT hub:

    • Subscription: Choose the subscription that you want to use to create this IoT hub.

    • Resource group: Create a resource group to host the IoT hub or use an existing one. For more information, see Use resource groups to manage your Azure resources.

    • Region: Select the closest location to you.

    • Name: Create a name for your IoT hub. If the name you enter is available, a green check mark appears.

    Important

    The IoT hub will be publicly discoverable as a DNS endpoint, so make sure to avoid any sensitive information while naming it.

    IoT Hub basics window

  4. Select Next: Size and scale to continue creating your IoT hub.

  5. Choose your Pricing and scale tier. For this article, select the F1 - Free tier if it's still available on your subscription. For more information, see the Pricing and scale tier.

    IoT Hub size and scale window

  6. Select Review + create.

  7. Review your IoT hub information, then click Create. Your IoT hub might take a few minutes to create. You can monitor the progress in the Notifications pane.

  8. When your new IoT hub is ready, click its tile in the Azure portal to open its properties window. Now that you have created an IoT hub, locate the important information that you use to connect devices and applications to your IoT hub. Click Shared access policies.

  9. In Shared access policies, select the iothubowner policy. Copy the IoT Hub Connection string---primary key to use later. For more information, see Access control in the "IoT Hub developer guide."

    Shared access policies

You have now created your IoT hub, and you have the host name and IoT Hub connection string that you need to complete the rest of this tutorial.

The next step is to link the Device Provisioning Service and IoT hub so that the IoT Hub Device Provisioning Service can register devices to that hub. The service can only provision devices to IoT hubs that have been linked to the Device Provisioning Service. Follow these steps.

  1. In the All resources page, click the Device Provisioning Service instance you created previously.
  2. In the Device Provisioning Service page, click Linked IoT hubs.
  3. Click Add.
  4. In the Add link to IoT hub page, provide the following information, and click Save:

    • Subscription: Make sure the subscription that contains the IoT hub is selected. You can link to IoT hub that resides in a different subscription.
    • IoT hub: Choose the name of the IoT hub that you want to link with this Device Provisioning Service instance.
    • Access Policy: Select iothubowner as the credentials to use for establishing the link to the IoT hub.

    Link the hub name to link to the Device Provisioning Service in the portal

Set the allocation policy on the Device Provisioning Service

The allocation policy is a IoT Hub Device Provisioning Service setting that determines how devices are assigned to an IoT hub. There are three supported allocation policies:

  1. Lowest latency: Devices are provisioned to an IoT hub based on the hub with the lowest latency to the device.
  2. Evenly weighted distribution (default): Linked IoT hubs are equally likely to have devices provisioned to them. This setting is the default. If you are provisioning devices to only one IoT hub, you can keep this setting.
  3. Static configuration via the enrollment list: Specification of the desired IoT hub in the enrollment list takes priority over the Device Provisioning Service-level allocation policy.

To set the allocation policy, in the Device Provisioning Service page click Manage allocation policy. Make sure the allocation policy is set to Evenly weighted distribution (the default). If you make any changes, click Save when you are done.

Manage allocation policy

Clean up resources

Other tutorials in this collection build upon this tutorial. If you plan to continue on to work with subsequent quick starts or with the tutorials, do not clean up the resources created in this tutorial. If you do not plan to continue, use the following steps to delete all resources created by this tutorial in the Azure portal.

  1. From the left-hand menu in the Azure portal, click All resources and then select your IoT Hub Device Provisioning Service instance. At the top of the All resources page, click Delete.
  2. From the left-hand menu in the Azure portal, click All resources and then select your IoT hub. At the top of the All resources page, click Delete.

Next steps

In this tutorial, you learned how to:

  • Use the Azure portal to create an IoT Hub Device Provisioning Service and get the ID scope
  • Create an IoT hub
  • Link the IoT hub to the Device Provisioning Service
  • Set the allocation policy on the Device Provisioning Service

Advance to the next tutorial to learn how to set up your device for provisioning.