You have around 200 field devices that need to be provisioned automatically using the Device Provisioning Service mi-dps-001
You want the devices to be randomly distributed between two existing IoT Hubs (my-hub-001, my-hub-001)
You use the following CLI command to tell the DPS which hubs to connect to: az iot dps linked-hub create --dps-name mi-dps-001 --resource-group mi-resource-group-001 --connection-string $hubConnectionString --location westus You try this command to retrieve get the hubConnectionString for mi-hub-001:
az iot hub show-connection-string --name mi-hub-001 --key primary --query connectionString -o tsvIs that the right way to get the parameter value?
Click on the arrows to vote for the correct answer
A. B.Correct Answer: A.
Option A is CORRECT because in order to link your DPS resource to your existing IoT Hub, you need to use this command to get the connection string and use its output.
Option B is incorrect because actually, the show-connection-string CLI command is designed to query the connection string of an existing IoT Hub.
References:
No, the command provided to retrieve the hubConnectionString for mi-hub-001 is not correct.
The command to retrieve the hubConnectionString for mi-hub-001 should be:
cssaz iot hub show-connection-string --hub-name mi-hub-001 --query connectionString --policy-name iothubowner --output tsv
This command will retrieve the connection string for the IoT hub named mi-hub-001. The --policy-name
parameter specifies the name of the policy to use for the connection string. In this case, iothubowner
is used, which is the built-in policy that provides full access to the IoT hub.
After obtaining the connection string for mi-hub-001, it can be used in the az iot dps linked-hub create
command to link the IoT hub to the Device Provisioning Service. The --connection-string
parameter in the az iot dps linked-hub create
command should be set to the connection string for the IoT hub.