Examine Azure CLI support for device provisioning

Completed

You can use Azure CLI commands to accomplish many of the tasks associated with the Azure IoT Hub Device Provisioning Service (DPS).

Azure IoT extension for Azure CLI

To use Azure CLI commands, you must first install the Azure IoT extension for Azure CLI using the following command:

az extension add --name azure-iot

Azure CLI commands for DPS

DPS service management commands

You can use az iot dps Azure CLI commands to manage Device Provisioning Service instances. The DPS service commands are listed as follows:

Command Description
az iot dps create Create an Azure IoT Hub Device Provisioning Service instance.
az iot dps delete Delete an Azure IoT Hub Device Provisioning Service instance.
az iot dps list List Azure IoT Hub Device Provisioning Service instances.
az iot dps show Get the details of an Azure IoT Hub Device Provisioning Service instance.
az iot dps update Update an Azure IoT Hub Device Provisioning Service instance.

Other DPS command categories

Other Azure CLI Commands for DPS are available in the following categories:

Category Description
certificate Manage certificates for an Azure IoT Hub Device Provisioning Service instance.
connection-string Manage connection strings for an Azure IoT Hub Device Provisioning Service instance.
enrollment Manage individual device enrollments in an Azure IoT Hub Device Provisioning Service.
enrollment-group Manage enrollment groups in an Azure IoT Hub Device Provisioning Service.
linked-hub Manage linked IoT Hubs in an Azure IoT Hub Device Provisioning Service instance.
policy Manage shared access policies for an Azure IoT Hub Device Provisioning Service instance.

Use the DPS commands

DPS commands have required and optional arguments. The DPS Azure CLI create and delete service commands are listed as examples. See documentation or use the --help command argument for argument details.

DPS create command

Use the az iot dps create command to create an Azure IoT Hub Device Provisioning Service instance.

--name and --resource-group arguments are required. Required and frequently used optional arguments are listed in this table.

Command arguments

Description

--name

Device Provisioning Service name. --name is a required argument.

--resource-group

Name of resource group. --resource-group is a required argument.

--location

Location of your IoT Provisioning Service. Default is the location of target resource group.

--sku

Pricing tier for the IoT provisioning service. Allowed values: S1. Default: S1.

--unit

Units in your IoT Provisioning Service. Default: 1.

For example, the following command can be used to create an Azure IoT Hub Device Provisioning Service with the standard pricing tier S1, in the region of the resource group:

az iot dps create --name MyDps --resource-group MyResourceGroup

Or, to create an Azure IoT Hub Device Provisioning Service with the standard pricing tier S1, in the eastus region, use the following command:

az iot dps create --name MyDps --resource-group MyResourceGroup --location eastus

Delete command

The az iot dps delete command can be used to delete an Azure IoT Hub Device Provisioning Service instance.

--name and --resource-group arguments are required. Required and frequently used optional arguments are listed in this table.

This command takes the following arguments:

Command arguments

Description

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name

IoT Provisioning Service name.

--resource-group

Name of resource group.

--subscription

Name or ID of subscription.

For example, the following command can be used to delete an Azure IoT Hub Device Provisioning Service named MyDps:

az iot dps delete --name MyDps --resource-group MyResourceGroup