0

I want to automatically associate my device with its template. There is an article about this here: https://learn.microsoft.com/en-us/azure/iot-central/core/concepts-get-connected#automatically-associate-with-a-device-template

the sample code for this is in JS and says to include iotcModelId: '< this is the URN for the capability model>'; OR '__iot:interfaces': { CapabilityModelId: <this is the URN for the capability model> }

I can see in the python device SDK documentation on keyword args available during client creation. https://github.com/Azure/azure-iot-sdk-python/wiki/key-word-arguments-during-client-creations

But I don't see anything in those keywords about the device template. I've tried a couple of permutations on my own, but nothing seems to work as I'm registering my device using ProvisioningDeviceClient.create_from_x509_certificate.

Anyone know the correct way to include the device template in the registration?

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
Patrick
  • 2,044
  • 1
  • 25
  • 44

2 Answers2

1

Once you have created your ProvisioningDeviceClient you need to set the provisioning_payload property to the JSON string that contains your model-id per documentation you have linked above.

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
  • Thank you! "provisioning_payload" was the keyword I missing. I don't see it mentioned in those pages. Here are more specifics for the next person: `provisioning_device_client.provisioning_payload = {"modelId": "your_device_template_URN"} ` The URN is the `Interface @id` which is found when you View Identity on the Template itself. – Patrick Nov 13 '20 at 20:13
0

There's a tutorial and sample on Microsoft Docs that illustrates this using Python: Tutorial: Create and connect a client application to your Azure IoT Central application.

Dominic Betts
  • 2,306
  • 1
  • 18
  • 10