2

Using the Node SDK, I have programmatically created devices in IoT Hub. I wish to know if the Node SDK provides me the capability to set a device as a child of another device.

Looking at the documentation, I didn't find a way (using SDK). Is there any other way to achieve the same ?

Salomi Edward
  • 533
  • 4
  • 15

1 Answers1

1

As far as I can see and as you found, the SDK doesn't let you create parent/child relationships for devices (https://learn.microsoft.com/javascript/api/azure-iothub/devicescreateorupdateidentityoptionalparams?view=azure-node-latest).

However, the REST API does support this using the deviceScope parameter (https://learn.microsoft.com/en-us/rest/api/iothub/service/devices/create-or-update-identity).

You might find more information here: How to programmatically set a parent device while creating an Azure IoT Hub device?

Dominic Betts
  • 2,306
  • 1
  • 18
  • 10
  • Can you please explain in detail (maybe with a small example) how can I use deviceScope parameter. I had checked the question you have linked, the answer on the question refers to C# SDK which has this feature and I am looking for the same in Node – Salomi Edward Sep 29 '21 at 10:29
  • Thank you so much. This worked! For anybody who is still stuck on this. I had followed this - https://stackoverflow.com/questions/63792034/azure-iot-edge-programmaticallynodejs-create-parent-child-relation-between-edg – Salomi Edward Sep 29 '21 at 11:55