Set Up an IoT Hub Device Provisioning Service With Azure CLI

DZone 's Guide to

Set Up an IoT Hub Device Provisioning Service With Azure CLI

Learn more about setting up your own IoT Hub with Azure Cloud.

· IoT Zone ·
Free Resource

Image title

The Azure CLI is employed to make and manage Azure resources from instructions or scripts. This QuickStart details the exploitation of the Azure CLI and how to make an IoT Hub and device provisioning service, linking to two services along the way.

1. Open Azure Cloud Shell

Azure Cloud Shell is a free, interactive shell that you will run during this article. Common Azure tools square measure preinstalled and designed in Cloud Shell for you to use along with your account. Simply choose the Copy button to repeat the code, paste it in the Cloud Shell, and press Enter to run it. The square measures a number of ways to open Cloud Shell:

Image title

2. Create an IoT Hub

Create an IoT Hub with the az IoT Hub produce command.

The following example creates an IoT Hub named my-sample-hub within the west location:

Image title

2. Create a Provisioning Service

Create a provisioning service with the Azure IoT DPS produce command.

The following example creates an provisioning service named my-sample-dps within the west location.

Image title

3. Get the Association String for the IoT Hub

You need your IoT hub's association string to link it with the Device Provisioning Service. Use the az iot hub show-connection-string command to urge the association string and use its output to line a variable that you just can use after you link the 2 resources.

The following example sets the hubConnectionString variable to the worth of the association string for the first key of the hub's iothubowner policy. you'll be able to specify a unique policy with the --policy-name parameter. The command uses the Azure CLI question and output choices to extract the association string from the command output.

Image title

4. Link the IoT Hub and the Provisioning Service

Link the IoT hub and your provisioning service with the Azure IoT DPS linked-hub produce command.

The following example links an IoT Hub named my-sample-hub within the west location and a tool provisioning service named my-sample-dps. It uses the association string for my-sample-hub keep within the hubConnectionString variable within the previous step.

Image title

5. Verify the Provisioning Service

Get the main points of your provisioning service with the Azure IoT DPS show command.

The following example gets the main points of a provisioning service named my-sample-dps. The connected IoT Hub is shown within the properties.iotHubs assortment.

Image title

6. Clean Up Resources

Other Quickstarts during this assortment hinge upon this Quickstart. If you propose to continue on to figure with later Quickstarts or with the tutorials, don't close up the resources created during this Quickstart. If you are doing not arrange to continue, you'll be able to use the subsequent commands to delete the provisioning service, the IoT Hub, or the resource cluster and every one of its resources.

To delete the provisioning service, run the Azure IoT DPS delete command:

Image title

Next Steps

In this Quickstart, you’ve deployed an IoT Hub and a tool provisioning service instance by connecting two resources. To be told, the way we use this originated with a provision and a simulated device. However, when using Quickstart to make a simulated device, you become skilled in programming and creating the Azure IoT Hub.

azure, azure cli, azure tutorial, cli, device provisioning, iot, iot hub, iot tutorial, tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}