You have just created a device identity in your IoT Hub named mytemphub-001
You want to enable your back-end application to connect to this IoT hub and to access the messages.
You need a connection string which you retrieve by the following CLI command:
az iot hub connection-string show \ --policy-name service \ --name {YourIoTHubName} \ --output tableIs that the command you should use?
Click on the arrows to vote for the correct answer
A. B.Correct Answer: A.
Option A is CORRECT because to enable back-end applications to connect to your IoT hub you need the service connection string which can be retrieved by the command above.
Option B is incorrect because the command above is actually for retrieving the service connection string needed by the back-end applications.
Field devices would need adevice connection string:
<pre class="brush:java;">az iot hub device-identity connection-string show --hub-name {YourIoTHubName} --device-id MyPythonDevice --output table.
</pre>
Reference:
Yes, the given command is correct and should be used to retrieve the connection string for the service policy of your IoT Hub.
Let's break down the command and understand what each parameter does:
Once you run this command in the Azure CLI, you should see the connection string for the service policy of your IoT Hub in the output. You can copy and use this connection string in your back-end application to access the IoT Hub and retrieve messages.