What are the free tutorials for SAS

Tutorial: Configuring Cloud Resources for Device Provisioning Using IoT Hub Device Provisioning Service

  • 7 minutes to read

This tutorial shows how to set up the cloud for automatic device provisioning using the IoT Hub Device Provisioning service. In this tutorial you will learn how to do the following tasks:

  • Create an IoT Hub Device Provisioning service and get the ID range using the Azure portal
  • Create an IoT hub
  • Linking the IoT Hub to the Device Provisioning Service
  • Set the mapping policy in the Device Provisioning Service

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


Sign in to the Azure portal.

Create a device provisioning service instance and get the ID range

To create a new Device Provisioning Service Instance, do the following:

  1. In the Azure portal, click in the upper left corner Create resource.

  2. Enter in the search box Device provisioning a.

  3. click on IoT Hub Device Provisioning Service.

  4. Enter in the form IoT Hub Device Provisioning Service the following information:

    attitudeSuggested valuedescription
    SurnameAny unique name--
    subscriptionYour subscriptionFor details on your subscriptions, see Subscriptions.
    Resource groupmyResourceGroupFor valid resource group names, see Naming rules and restrictions.
    LocationValid locationFor information on regions, see Azure regions.

  5. click on Create. After a few moments, the Device Provisioning Service instance will be created and the page Overview displayed.

  6. Copy on the side Overview for the new service instance the value for ID range for later use. The value is used to identify registration IDs and ensure that the registration ID is unique.

  7. Also copy the value below Service endpoint for later use.

Create an IoT hub

This section describes how to create an IoT hub through the Azure portal:

  1. Sign in to the Azure portal.

  2. On the Azure home page, choose the button + Create resource and then type in the field Search the marketplace the term IoT hub a.

  3. Select in the search results IoT hub and then Create out.

  4. Fill in the tab Basic settings the fields as follows:

    • subscription: Select the subscription you want to use for your hub.

    • Resource group: Select an existing resource group or create a new one. To create a new resource group, select Create new and enter the name you want to use. If you want to use an existing resource group, select the appropriate resource group. For more information, see Manage Azure Resource Manager Resource Groups.

    • region: Select the region where you want your hub to be located. Select the location that is closest to you. Some features, such as IoT Hub device streams, are only available in certain regions. For these restricted features, you must select one of the supported regions.

    • IoT hub name: Enter a name for the hub. This name must be globally unique.


    The IoT hub can be publicly identified as a DNS endpoint. Therefore, make sure that you do not use any sensitive or personal information when assigning the name.

  5. click on Next: Networkto continue building your hub.

    Select the endpoints that can connect to the IoT Hub. You can choose the default Public endpoint (all networks) select or the option Public endpoint (selected IP address ranges) or Private endpoint establish. For this example, accept the default setting.

  6. click on Next: Administrationto continue building your hub.

    You can accept the standard settings here. You can customize the following fields if necessary:

    • Tariff and scaling: Your selected level. You have several plans to choose from, depending on how many features you use and how many messages you want to send about your solution each day. The free plan is intended for testing and evaluation. This enables a connection to the hub for 500 devices and up to 8,000 messages per day are possible. Any Azure subscription can create an IoT hub in the free plan.

      If you're working through a quick start guide for IoT Hub device streams, select the Free plan.

    • IoT hub units: The number of messages allowed per unit per day depends on your hub tariff. For example, if you want the hub to support 700,000 incoming messages, choose two S1 tariff units. For details on the other tariff options, see Scaling an IoT Hub Solution.

    • Defender for IoT: Enable this option to add an extra layer of threat protection to IoT and your devices. This option is not available for hubs in the free tier. For more information on this feature, see the Azure Security Center for IoT documentation.

    • Advanced settings > Device-to-cloud partitions: This property sets the device-to-cloud messages in relation to the number of simultaneous readers of the messages. Most hubs only need four partitions.

  7. click on Next: Tagsto proceed to the next screen.

    Tags are name-value pairs. You can assign the same tag to multiple resources and resource groups to categorize resources and consolidate billing. For more information, see Use tags to organize Azure resources.

  8. click on Next: Review + createto review your selection. It looks something like the following screen, except that it uses the values ​​you selected when you created the hub.

  9. Choose Create to create your new hub. It takes a few minutes to create the hub.

Get the connection string for the IoT hub

After creating your hub, get the connection string for the hub. This is used to connect devices and applications to the hub.

  1. Click on your hub to display the IoT Hub area with settings and other items. click on SAS guidelines.

  2. Choose under Shared access policies the directive iothubowner out.

  3. Copy below Shared access key the value of Connection string - primary key for later use.

    For more information, see Access Control in the Azure IoT Hub Development Guide.

You have now created your IoT hub and have the host name and IoT hub connection string that you will need for the rest of the steps in this tutorial.

Link the device provisioning service to an IoT hub instance

The next step is to link the device provisioning service and the IoT hub so that the IoT hub device provisioning service can register devices with this hub. The service can only provide devices with IoT hubs that have been linked to the device provisioning service. Follow the steps below.

  1. Click on the side All resources to the Device Provisioning service instance that you created earlier.

  2. On the Device Provisioning Service page, click Linked IoT hubs.

  3. click on Add.

  4. Enter on the side Add link to IoT Hub Enter the following information and click to save:

    • Subscription: Make sure the subscription with the IoT Hub instance is selected. You can link to an IoT Hub instance that is included in another subscription.

    • IoT Hub: Select the name of the IoT Hub instance that you want to associate with this Device Provisioning Service instance.

    • Access Policy: Choose iothubowner as credentials for creating the link to the IoT Hub instance.

Set the mapping policy in the Device Provisioning Service

The assignment policy is a setting of the IoT Hub Device Provisioning service that determines how devices are assigned to an IoT Hub instance. There are three supported mapping policies:

  1. Lowest latency: Devices are provisioned to an IoT Hub instance based on the hub with the lowest latency on the device.

  2. Evenly weighted distribution (Default): Linked IoT hubs are equally likely to be provided with devices. This is the default setting. If you only provide devices for one IoT Hub instance, you can keep this setting.

  3. Static configuration via the registration list: The specification of the desired IoT Hub instance in the registration list has priority over the assignment policy at the level of the device provisioning service.

To set the mapping policy, click on the Device Provisioning Service page Manage mapping policy. Make sure that the mapping policy is on Evenly weighted distribution (Default) is set. If you make any changes, click afterwards to save.

Cleaning up resources

Other tutorials in this collection build on this tutorial. If you plan to continue with the quickstarts or tutorials below, do not clean up the resources created in this tutorial. In case you don't want to continue, you can follow the steps below to delete all of the resources created in this tutorial in the Azure portal.

  1. In the Azure portal, click in the menu on the left All resourcesand select your IoT Hub Device Provisioning service instance. Click at the top of the page All resources on Clear.

  2. In the Azure portal, click in the menu on the left All resourcesand select your IoT Hub instance. Click at the top of the page All resources on Clear.

Next Steps

In this tutorial, you learned the following:

  • Create an IoT Hub Device Provisioning service and get the ID range using the Azure portal
  • Create an IoT hub
  • Linking the IoT Hub to the Device Provisioning Service
  • Set the mapping policy in the Device Provisioning Service

Skip to the next tutorial to learn how to configure your device for deployment.