You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-maps/tutorial-iot-hub-maps.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -279,7 +279,7 @@ To learn more about how to send device-to-cloud telemetry, and the other way aro
279
279
[geofence JSON data file]: https://raw.githubusercontent.com/Azure-Samples/iothub-to-azure-maps-geofencing/master/src/Data/geofence.json?token=AKD25BYJYKDJBJ55PT62N4C5LRNN4
280
280
[Plug and Play schema for geospatial data]: https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v1-preview/schemas/geospatial.md
281
281
[Postman]: https://www.postman.com/
282
-
[register a new device in the IoT hub]: ../iot-hub/iot-hub-create-through-portal.md#register-a-new-device-in-the-iot-hub
282
+
[register a new device in the IoT hub]: ../iot-hub/create-connect-device.md
Copy file name to clipboardExpand all lines: articles/iot-hub/create-connect-device.md
+96-26Lines changed: 96 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,24 +7,36 @@ author: kgremban
7
7
ms.author: kgremban
8
8
ms.service: iot-hub
9
9
ms.topic: how-to
10
-
ms.date: 06/10/2024
10
+
ms.date: 06/12/2024
11
11
---
12
12
13
13
# Create and manage device identities
14
14
15
15
Create a device identity for your device to connect to Azure IoT Hub. This article introduces key tasks for managing a device identity including registering the device, collecting its connection information, and then deleting or disabling a device at the end of its lifecycle.
16
16
17
+
## Prerequisites
18
+
19
+
* An IoT hub in your subscription. If you don't have an IoT hub, follow the steps in [Create an IoT hub](./iot-hub-create-through-portal.md)
20
+
17
21
## Register a device
18
22
19
23
In this section, you create a device identity in the [identity registry in your IoT hub](./iot-hub-devguide-identity-registry.md). A device can't connect to a hub unless it has a device identity.
20
24
21
25
The IoT Hub identity registry only stores device identities to enable secure access to the IoT hub. It stores device IDs and keys to use as security credentials, and an enabled/disabled flag that you can use to disable access for an individual device.
22
26
23
-
IoT Hub supports three methods for device authentication:
27
+
When you register a device, you choose its authentication method. IoT Hub supports three methods for device authentication:
28
+
29
+
***Symmetric key** - *This option is recommended for quickstart scenarios.*
30
+
31
+
When you register a device, you can provide keys or IoT Hub will generate keys for you. Both the device and the IoT hub have a copy of the symmetric key that can be compared when the device connects.
32
+
33
+
***X.509 self-signed**
34
+
35
+
If your device has a self-signed X.509 certificate, then you need to give IoT Hub a version of the certificate for authentication. When you register a device, you upload a certificate *thumbprint*, which is a hash of the device's X.509 certificate. When the device connects, it presents its certificate and the IoT hub can validate it against the hash it knows. For more information, see [Authenticate identities with X.509 certificates](./authenticate-authorize-x509.md).
36
+
37
+
***X.509 CA signed** - *This option is recommended for production scenarios.*
24
38
25
-
***Symmetric key** - When you register a device, you can provide keys or IoT Hub will generate keys for you. Both the device and the IoT hub have a copy of the symmetric key that can be compared when the device connects.
26
-
***X.509 self-signed** - If your device has a self-signed X.509 certificate, then you need to give IoT Hub a version of the certificate for authentication. When you register a device, you upload a certificate *thumbprint*, which is a hash of the device's X.509 certificate. When the device connects, it presents its certificate and the IoT hub can validate it against the hash it knows. For more information, see [Authenticate identities with X.509 certificates](./authenticate-authorize-x509.md).
27
-
***X.509 CA signed** - If your device has a CA-signed X.509 certificate, then you can give IoT Hub a root or intermediate certificate in the signing chain for authentication. *This option is recommended for production scenarios.* Before you register a device, you upload and verify an X.509 certificate authority (CA) certificate to the IoT hub. The device has an X.509 certificate with the verified X.509 CA in its certificate chain of trust. When the device connects, it presents its full certificate chain and the IoT hub can validate it because it knows the X.509 CA. Multiple devices can authenticate against the same verified X.509 CA. For more information, see [Authenticate identities with X.509 certificates](./authenticate-authorize-x509.md).
39
+
If your device has a CA-signed X.509 certificate, then you can give IoT Hub a root or intermediate certificate in the signing chain for authentication. Before you register a device, you upload and verify an X.509 certificate authority (CA) certificate to the IoT hub. The device has an X.509 certificate with the verified X.509 CA in its certificate chain of trust. When the device connects, it presents its full certificate chain and the IoT hub can validate it because it knows the X.509 CA. Multiple devices can authenticate against the same verified X.509 CA. For more information, see [Authenticate identities with X.509 certificates](./authenticate-authorize-x509.md).
28
40
29
41
### Prepare certificates
30
42
@@ -38,18 +50,17 @@ If your device uses self-signed certificates, then you need two device certifica
1. In the [Azure portal](https://portal.azure.com), navigate to your IoT hub.
52
-
1. Select **Device management** > **Devices**, then select **Add Device** to add a device in your IoT hub.
60
+
61
+
1. Select **Device management** > **Devices**.
62
+
63
+
1. Select **Add Device** to add a device in your IoT hub.
53
64
54
65
<!-- :::image type="content" source="./media/iot-hub-include-create-device/create-identity-portal.png" alt-text="Screen capture that shows how to create a device identity in the portal." border="true"::: -->
Use the [az iot hub device-identity create](/cli/azure/iot/hub/device-identity#az-iot-hub-device-identity-create) command to register a device.
83
+
84
+
The following table describes common parameters used with this command.
85
+
86
+
| Parameter | Dependent parameter | Value |
87
+
| -- | -- | -- |
88
+
|`--device-id`, `-d`|| Provide a name for your new device. |
89
+
|`--hub-name`, `-h`|| IoT hub name or hostname. |
90
+
|`--auth-method`, `--am`|| Either `shared_private_key`, `x509_ca`, or `x509_thumbprint`|
91
+
||`--primary-key`, `--pk` and `--secondary-key`, `--sk`| Use with `shared_private_key` authentication if you want to provide the primary and secondary keys for your device. Omit if you want IoT Hub to generate the keys. |
92
+
||`--primary-thumbprint`, `--ptp` and `--secondary-thumbprint`, `--stp`| Use with `x509_thumbprint` authentication to provide the primary and secondary certificate thumbprints for your device. Omit if you want IoT Hub to generate a self-signed certificate and use its thumbprint. |
Registered devices have multiple ways to connect to IoT Hub, depending on the SDK and authentication method. For specific information, refer to the [Azure IoT Hub device SDKs](./iot-hub-devguide-sdks.md#azure-iot-hub-device-sdks).
101
+
102
+
For samples and test scenarios, the most common connection method is to use a *device connection string*. A device connection string contains the name of the IoT hub, the name of the device, and the device's authentication information.
103
+
104
+
Device with symmetric key authentication have a connection string with the following pattern:
Devices with X.509 authentication, either self-signed or CA-signed, usually don't use connection strings for authentication. When they do, their connection strings take the following pattern:
You can build a connection string yourself with those three pieces of connection information, or you can retrieve it with the following steps.
113
+
78
114
### [Azure portal](#tab/portal)
79
115
80
-
1. After the device is created, open the device from the list in the **Devices** pane. Copy the value of **Primary connection string**. This connection string is used by device code to communicate with the IoT hub.
116
+
The Azure portal only lists connection strings for devices that use symmetric key authentication.
117
+
118
+
1. In the [Azure portal](https://portal.azure.com), navigate to your IoT hub.
119
+
120
+
1. Select **Device management** > **Devices**.
121
+
122
+
1. Select your device from the list in the **Devices** pane.
123
+
124
+
1. Copy the value of **Primary connection string**.
81
125
82
126
By default, the keys and connection strings are masked because they're sensitive information. If you click the eye icon, they're revealed. It's not necessary to reveal them to copy them with the copy button.
83
127
84
128
<!-- :::image type="content" source="./media/iot-hub-include-create-device/device-details.png" alt-text="Screen capture that shows the device connection string." border="true" lightbox="./media/iot-hub-include-create-device/device-details.png"::: -->
85
129
86
130
### [Azure CLI](#tab/cli)
87
131
88
-
### [PowerShell](#tab/powershell)
132
+
Use the [az iot hub device-identity connection-string show](/cli/azure/iot/hub/device-identity#az-iot-hub-device-identity-connection-string-show) command to retrieve a device's connection string. For example:
133
+
134
+
```bash
135
+
az iot hub device-identity connection-string show --device-id <DEVICE_NAME> --hub-name <IOT_HUB_NAME>
136
+
```
89
137
90
138
---
91
139
@@ -95,26 +143,48 @@ If you want to keep a device in your IoT hub's identity registry, but want to pr
95
143
96
144
### [Azure portal](#tab/portal)
97
145
98
-
1. In the [Azure portal](https://portal.azure.com), navigate to your IoT hub.
146
+
. In the [Azure portal](https://portal.azure.com), navigate to your IoT hub.
99
147
100
-
1. Select **Devices**from the navigation menu.
148
+
1. Select **Device management**> **Devices**.
101
149
102
-
1. Select the name of the device that you want to disable to view its device details page.
150
+
1. Select your device from the list in the **Devices** pane.
103
151
104
152
1. On the device details page, set the **Enable connection to IoT Hub** parameter to **Disable**.
105
153
106
154
:::image type="content" source="./media/iot-hub-create-through-portal/disable-device.png" alt-text="Screenshot that shows disabling a device connection.":::
107
155
108
-
If you want to remove a device from your IoT hub's identity registry, you can delete its registration.
109
-
110
-
1. From the **Devices** page of your IoT hub, select the checkbox next to the device that you want to delete.
111
-
112
-
1. Select **Delete** to remove the device registration.
156
+
If you want to remove a device from your IoT hub's identity registry, you can delete its registration by selecting **Delete**.
113
157
114
158
:::image type="content" source="./media/iot-hub-create-through-portal/delete-device.png" alt-text="Screenshot that shows deleting a device.":::
115
159
116
160
### [Azure CLI](#tab/cli)
117
161
118
-
### [PowerShell](#tab/powershell)
162
+
To disable a device, use the [az iot hub device-identity update](/cli/azure/iot/hub/device-identity#az-iot-hub-device-identity-update) command and change the `status` of the device. For example:
To delete a device, use the [az iot hub device-identity delete](/cli/azure/iot/hub/device-identity#az-iot-hub-device-identity-delete) command. For example:
169
+
170
+
```bash
171
+
az iot hub device-identity delete --device-id <DEVICE_NAME> --hub-name <IOT_HUB_NAME>
172
+
```
173
+
174
+
---
175
+
176
+
## Other tools for managing device identities
177
+
178
+
You can use other tools or interfaces to manage the IoT Hub identity registry, including:
179
+
180
+
* PowerShell commands
181
+
182
+
Refer to the [Az.IotHub](/powershell/module/az.iothub/) command set to learn how to manage device identities.
183
+
184
+
* Visual Studio Code
185
+
186
+
The [Azure IoT Hub extension for Visual Studio Code](./reference-iot-hub-extension.md) includes identity registry capabilities.
187
+
188
+
* REST API
119
189
120
-
---
190
+
Refer to the [IoT Hub Service APIs](/rest/api/iothub/service/devices) to learn how to manage device identities.
0 commit comments