Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
463 stars 493 forks source link

[Bug Report][v2] [IoTSDK] Issue with getting the Provisioning device client with symmetric key sample to work. #3363

Closed tweickmans closed 9 months ago

tweickmans commented 1 year ago

Hello I implemented communication between a device and a IotHub. I use previews/v2 SDK

Context

OS, version, SKU and CPU architecture used: Windows 10 Enterprise | Intel(R) Core(TM) i7 Application's .NET Target Framework : net6.0 Device: Laptop SDK version used: v2-preview007

Description of the issue

In the public async Task RunSampleAsync() method of ProvisioningDeviceClientSample.cs, the following code is called: image

Unfortunately, the AuthenticationProviderSymmetricKey constructor does not work. It generates an exception: 'argument couldn't be null' (for secondaryKey).

due to the constructor definition: image

To resolve this, you probably need to either modify the constructor of AuthenticationProviderSymmetricKey to accept the secondaryKey parameter as null, or update the example code to use primaryKey and secondaryKey.

It's not very clear in my mind whether it's necessary to provide the secondaryKey. In the v1 version of the SDK, it was possible to provide only the primaryKey to SecurityProviderSymmetricKey

timtay-microsoft commented 9 months ago

The fix has been checked in, so I'll close this thread