The connection string has an invalid value for property: DeviceId

Alexandre Alison 36 Reputation points
2020-11-02T09:36:01.637+00:00

Hello,

In our software, we use an already defined device named "IoTDeviceCheck" (deviceId) to setup the connection with our IOT hub.

It is possible to create a DeviceClient with such deviceId with most culture info (en-us, de-ch,..) but not with "tr-TR" : it throws an exception "The connection string has an invalid value for property: DeviceId". Because in IotHubConnectionStringBuilder:ValidateFormat, regex.IsMatch(value) returns false.

The regex (IdNameRegex) for idName is "^[A-Za-z0-9-:.+%_#*?!(),=@;$']{1,128}$" with regexOptions = RegexOptions.Compiled | RegexOptions.IgnoreCase;

In Turkhish, this fails because the "i" character does not seem to match the a-z part of the regular expression (and because the RegexOptions.CultureInvariant is not used).

We now perform the setup of the communication using in a CultureInfo.InvariantCulture task and it solves the problem.

So this means that HostName, IdName and SharedAccessKeyName are culture dependent.

We had this issue only on setup but our application can be used by customers from many countries (so a device id could be created on a culture and then used in another one) so that could be a common limitation.

Could somebody confirm that HostName, IdName and SharedAccessKeyName are meant to be culture dependent? (I was not able to find any documentation about this).

(SharedAccessKeyRegex, SharedAccessSignatureRegex and X509CertRegex are also using the same regexOptions).

Thanks

Alex

Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
224 questions
{count} votes

Accepted answer
  1. António Sérgio Azevedo 7,671 Reputation points Microsoft Employee
    2020-12-28T16:53:01.48+00:00

    Hello @Alexandre Alison ,
    Thank you so much for your time. I have confirmed that the PR should fix the issue reported: https://github.com/Azure/azure-iot-sdk-csharp/pull/1716

    • Please confirm on your side by building the source code and testing;
    • Or you can wait for the next SDK release planed to the first week of January;
    • Alternatively we can provide you with a private SDK drop as well.

    We would love to hear from you once you try out the fix and if solved, please mark this as the answer to help others finding the best content easily :)!

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.