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/iot-hub/create-connect-device.md
+28-22Lines changed: 28 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
---
2
2
title: Register and connect an IoT device
3
3
titleSuffix: Azure IoT Hub
4
-
description: How to create, manage, and delete Azure IoT devices and how to retrieve their connection information.
4
+
description: How to create, manage, and delete Azure IoT devices and how to retrieve the device connection string.
5
5
author: kgremban
6
6
7
7
ms.author: kgremban
8
8
ms.service: iot-hub
9
9
ms.topic: how-to
10
-
ms.date: 06/12/2024
10
+
ms.date: 06/19/2024
11
11
---
12
12
13
13
# Create and manage device identities
@@ -16,10 +16,12 @@ Create a device identity for your device to connect to Azure IoT Hub. This artic
16
16
17
17
## Prerequisites
18
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)
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
20
21
21
* Depending on which tool you use, either have access to the [Azure portal](https://portal.azure.com) or [install the Azure CLI](/cli/azure/install-azure-cli).
22
22
23
+
* If your IoT hub is managed with role-based access control (RBAC), then you need **Read/Write/Delete Device/Module** permissions for the steps in this article. Those permissions are included in [IoT Hub Registry Contributor](../role-based-access-control/built-in-roles/internet-of-things.md#iot-hub-registry-contributor) role.
24
+
23
25
## Register a device
24
26
25
27
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.
@@ -42,15 +44,15 @@ When you register a device, you choose its authentication method. IoT Hub suppor
42
44
43
45
### Prepare certificates
44
46
45
-
If you're using either of the X.509 certificate authentication methods, make sure your certificates are ready before registering a device.
47
+
If you're using either of the X.509 certificate authentication methods, make sure your certificates are ready before registering a device:
46
48
47
-
The tutorial [Create and upload certificates for testing](./tutorial-x509-test-certs.md) provides a good introduction for how to create CA-signed certificates and upload them to IoT Hub. After completing that tutorial, you're ready to register a device with **X.509 CA signed** authentication.
49
+
* For CA-signed certificates, the tutorial [Create and upload certificates for testing](./tutorial-x509-test-certs.md) provides a good introduction for how to create CA-signed certificates and upload them to IoT Hub. After completing that tutorial, you're ready to register a device with **X.509 CA signed** authentication.
48
50
49
-
If your device uses self-signed certificates, then you need two device certificates (a primary and a secondary certificate) on the device and thumbprints for both to upload to IoT Hub. One way to retrieve the thumbprint from a certificate is with the following OpenSSL command:
51
+
* For self-signed certificates, you need two device certificates (a primary and a secondary certificate) on the device and thumbprints for both to upload to IoT Hub. One way to retrieve the thumbprint from a certificate is with the following OpenSSL command:
@@ -64,6 +66,8 @@ Create a device identity in your IoT hub.
64
66
65
67
1. Select **Add Device** to add a device in your IoT hub.
66
68
69
+
:::image type="content" source="./media/create-connect-device/add-device.png" alt-text="Screenshot that shows adding a new device in the Azure portal.":::
70
+
67
71
1. In **Create a device**, provide the information for your new device identity:
68
72
69
73
| Parameter | Dependent parameter | Value |
@@ -95,25 +99,17 @@ The following table describes common parameters used with this command.
95
99
96
100
---
97
101
98
-
## Retrieve device connection information
99
-
100
-
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).
102
+
## Retrieve device connection string
101
103
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.
104
+
For samples and test scenarios, the most common connection method is to use symmetric key authentication and connect with 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
105
104
-
Device with symmetric key authentication have a connection string with the following pattern:
106
+
For information about other methods for connecting devices, particularly for X.509 authentication, refer to the [Azure IoT Hub device SDKs](./iot-hub-devguide-sdks.md#azure-iot-hub-device-sdks).
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.
108
+
Use the following steps to retrieve a device connection string.
113
109
114
110
### [Azure portal](#tab/portal)
115
111
116
-
The Azure portal only lists connection strings for devices that use symmetric key authentication.
112
+
The Azure portal provides device connection strings only for devices that use symmetric key authentication.
117
113
118
114
1. In the [Azure portal](https://portal.azure.com), navigate to your IoT hub.
119
115
@@ -123,6 +119,8 @@ The Azure portal only lists connection strings for devices that use symmetric ke
123
119
124
120
1. Copy the value of **Primary connection string**.
125
121
122
+
:::image type="content" source="./media/create-connect-device/copy-connection-string.png" alt-text="Screenshot that shows copying the value of the primary connection string from the Azure portal.":::
123
+
126
124
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.
127
125
128
126
### [Azure CLI](#tab/cli)
@@ -135,6 +133,14 @@ az iot hub device-identity connection-string show --device-id <DEVICE_NAME> --hu
135
133
136
134
---
137
135
136
+
Devices with symmetric key authentication have a device connection string with the following pattern:
Devices with X.509 authentication, either self-signed or CA-signed, usually don't use device connection strings for authentication. When they do, their connection strings take the following pattern:
0 commit comments