Connect IoT Device to Azure IoT Hub: Valid Connection Methods

IoT Device Connection Methods

Question

You need to connect your IoT device to the IoT Hub by using the open-source SDKs.

You've got a script as a template, which you need to customize with the connection method to link your device to the device identity:

... # The client object used to interact with your Azure IoT hub device_client = IoTHubDeviceClient.create_<...insert code here...> # Connect the client. await device_client.connect() ..

Which is not a valid connection method?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: C.

Option A is incorrect because you can instantiate a client using theX509 certificate by the create_from_x509_certificate method of the IotHubDeviceClient class.

Option B is incorrect because you can instantiate from the IoT Hub connection string of the device, by the create_from_connection_string method of the IotHubDeviceClient class.

Option C is CORRECT because the Primary key is the name of the symmetric shared access key of the device in the IoT Hub.

It is not a valid method name in the SDK.

Option D is incorrect because you can instantiate symmetric key authentication by the create_from_symmetric_key method of the IotHubDeviceClient class.

Diagram:

TestDevice01 ¥

MyHubLc001
© Message to Device > Direct Method -+ Add Module Identity = Device twin Gy Manage keys Y () Refresh
Device ID @ TestDevice01

Secondary Key @ eee

Primary Connection String @ eee

Secondary Connection String @ coO.

Enable connection to loT Hub @ © Enable O Disable
Parent device @ No parent device

&

Reference:

In order to connect an IoT device to an Azure IoT hub using open-source SDKs, you can use one of several connection methods provided by the SDKs. The given script uses the create_ method to initialize the device_client object with a connection method.

The connection methods that can be used with the create_ method are:

A. from_x509_certificate: This method creates a connection using a certificate and its associated private key. This method is typically used in scenarios where the device requires strong security measures.

B. from_connection_string: This method creates a connection using a connection string that contains the required information to connect to the Azure IoT hub. This method is typically used in scenarios where the device requires a simpler and less secure method of connecting to the IoT hub.

C. from_primary_key: This method creates a connection using a device's primary key, which is a secret value that is unique to each device. This method is typically used in scenarios where the device requires a higher level of security than a connection string provides, but not as much security as using a certificate.

D. from_symmetric_key: This method creates a connection using a symmetric key, which is a shared secret between the device and the IoT hub. This method is typically used in scenarios where the device requires a simpler and less secure method of connecting to the IoT hub, but more secure than a connection string.

Based on the above, all the connection methods A, B, C, and D are valid options for initializing the device_client object with a connection method. Therefore, none of them are invalid.