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: includes/iot-hub-howto-auth-device-cert-node.md
+19-4Lines changed: 19 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,15 +15,29 @@ The X.509 certificate is attached to the device-to-IoT Hub connection transport.
15
15
16
16
To configure a device-to-IoT Hub connection using an X.509 certificate:
17
17
18
-
1. Call [fromConnectionString](/javascript/api/azure-iothub/client?#azure-iothub-client-fromconnectionstring) to add the device connection string and transport type. Add `x509=true` to the device connection string to indicate that a certificate is added to `DeviceClientOptions`. For example: `HostName=xxxxx.azure-devices.net;DeviceId=Device-1;SharedAccessKey=xxxxxxxxxxxxx;x509=true`.
18
+
1. Call [fromConnectionString](/javascript/api/azure-iothub/client?#azure-iothub-client-fromconnectionstring) to add the device or identity module connection string, and transport type to the `Client` object. Add `x509=true` to the connection string to indicate that a certificate is added to `DeviceClientOptions`. For example:
1. Configure a JSON variable with certificate details and pass it to [DeviceClientOptions](/javascript/api/azure-iot-device/deviceclientoptions).
20
28
1. Call [setOptions](/javascript/api/azure-iot-device/client?#azure-iot-device-client-setoptions-1) to add an X.509 certificate and key (and optionally, passphrase) to the client transport.
21
29
1. Call [open](/javascript/api/azure-iothub/client?#azure-iothub-client-open) to open the connection from the device to IoT Hub.
22
30
23
-
This example shows certificate configuration information within a JSON variable. The certification configuration `options` are passed to `setOptions` and the connection is opened using `open`.
31
+
This example shows certificate configuration information within a JSON variable. The certification configuration `clientOptions` are passed to `setOptions`, and the connection is opened using `open`.
// Connection string illustrated for demonstration only. Never hard-code the connection string in production. Instead use an environmental variable or other secure storage.
> C#/.NET does not support connection of a device app to an IoT Hub module identity twin using a certificate.
60
+
58
61
### Retrieve a module identity twin and examine properties
59
62
60
63
Call [GetTwinAsync](/dotnet/api/microsoft.azure.devices.client.moduleclient.gettwinasync?#microsoft-azure-devices-client-moduleclient-gettwinasync) to retrieve the current module identity twin properties into a [Twin](/dotnet/api/microsoft.azure.devices.shared.twin?) object.
The [azure-iot-device](/javascript/api/azure-iot-device) package contains objects that interface with IoT devices. The [Twin](/javascript/api/azure-iot-device/twin) class includes twin-specific objects. This section describes `Client` class code that is used to read and write device module identity twin data.
29
29
30
-
### Install SDK packages
30
+
### Install SDK package
31
31
32
32
Run this command to install the **azure-iot-device** device SDK on your development machine:
33
33
34
34
```cmd/sh
35
35
npm install azure-iot-device --save
36
36
```
37
37
38
-
The [azure-iot-device](/javascript/api/azure-iot-device) package contains objects that interface with IoT devices. The [Twin](/javascript/api/azure-iot-device/twin) class includes twin-specific objects. This section describes `Client` class code that is used to read and write device module identity twin data.
38
+
### Connect a device to IoT Hub
39
+
40
+
A device app can authenticate with IoT Hub using the following methods:
For more information about the differences between MQTT, AMQP, and HTTPS support, see [Cloud-to-device communications guidance](../articles/iot-hub/iot-hub-devguide-c2d-guidance.md) and [Choose a device communication protocol](../articles/iot-hub/iot-hub-devguide-protocols.md).
59
68
60
-
### Create a client object
69
+
#####Create a client object
61
70
62
71
Create a `Client` object using the installed package.
63
72
@@ -67,7 +76,7 @@ For example:
67
76
constClient=require('azure-iot-device').Client;
68
77
```
69
78
70
-
### Create a protocol object
79
+
#####Create a protocol object
71
80
72
81
Create a `Protocol` object using an installed transport package.
73
82
@@ -77,7 +86,7 @@ This example assigns the AMQP protocol:
### Retrieve a module identity twin and examine reported properties
111
124
112
125
Call [getTwin](/javascript/api/azure-iot-device/client?#azure-iot-device-client-gettwin-1) to retrieve current module identity twin information into a [Twin](/javascript/api/azure-iot-device/twin) object.
> Python does not support connection of a device app to an IoT Hub module identity twin using a certificate.
85
+
83
86
### Retrieve a module identity twin and examine properties
84
87
85
88
Call [get_twin](/python/api/azure-iot-device/azure.iot.device.iothubmoduleclient?#azure-iot-device-iothubmoduleclient-get-twin) to retrieve the module identity twin from the Azure IoT Hub service. The twin information is placed into a variable that can be examined.
0 commit comments