question

ChrisHibberd-8717 avatar image
0 Votes"
ChrisHibberd-8717 asked ChrisHibberd-8717 commented

What are the restrictions on IoT device IDs?


https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#device-identity-properties states that deviceId is:

A case-sensitive string (up to 128 characters long) of ASCII 7-bit alphanumeric characters plus certain special characters: - . + % _ # * ? ! ( ) , : = @ $ '.

Yet when I create a device ID that contains the '=' character I am unable to register my device with the DPS (using an x509 certificate flow). Furthermore, the failed registrations do not appear in the DPS logs. For example:

YnECGGQQACFESqAAoAAA8g== fails to register as a device ID and no logs appear in the log analytics workspace.
YnECGGQQACFESqAAoAAA8g successfully registers as a device ID and logs appear in the log analytics workspace.

I am using version 2.5.1 of the Python azure-iot-device SDK.

Please could you confirm if the document I linked is correct and that YnECGGQQACFESqAAoAAA8g== should be a valid deviceId?

Thanks

azure-iot-hubazure-iot-dps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SandervandeVelde42 avatar image
0 Votes"
SandervandeVelde42 answered ChrisHibberd-8717 commented

Hello @ChrisHibberd-8717 ,

this is an interesting observation.

I was able to enter both DeviceIDs in an IoTHub:

143914-image.png

So, this IoTHub does not seem to be the issue.

In the DPS, I can register that DeviceID, only the RegistrationID must be simplified:

143971-image.png

(I use individual enrollment, symmetric key)

So the registration works by hand:

143962-image.png

I tried this with a code example from the Github repo Python Azure IoT Device SDK:

143910-image.png

So enrollment and assignment works with symmetric keys using a Python SDK example.

Please check if this works for you too. If so, try the X509 sample.


image.png (63.1 KiB)
image.png (11.4 KiB)
image.png (46.0 KiB)
image.png (56.8 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for clarifying this Sander. I had missed that the device id and registration id had different constraints. We can adjust our ID encoding to satisfy the stricter set of requirements.

Registration ID: https://docs.microsoft.com/en-us/azure/iot-dps/concepts-service#registration-id
Device ID: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#device-identity-properties

Out of interest, are there any docs that give example scenarios for where it would be useful to have different values for device ID and registration ID?

Best regards,

Chris

0 Votes 0 ·

Hello @ChrisHibberd-8717 ,

great to hear this made the difference.

We keep the RegistrationID on par with the device unique idenfication like serial number or mac address.

Each device has unique properties, tags, purpose, etc. so we want to use the enrollment for a unique device.

Using a registrationid which is also seen on the package is great for the engineer who gets multiple boxes with devices to be installed. So, we are use the device, with the right enrollment is connected at the right location.

1 Vote 1 ·