How to send custom payload while provisioning device in Azure IoT?

Tags: , , , ,

I am trying to provision my device into Azure IoT using Azure IoT Device Provisioning Service in which I am using the custom allocation policy, under manage enrollment group.

When the device registers to DPS (device provisioning service), it triggers an Azure Function in which I will decide which IoT Hub the device will be assigned to.

In my function, I have to take this decision based on some custom payload which I need to send from the device at the time of registering itself to DPS.

How will I send that custom payload from the device to the DPS at the time of registering itself, so I can get that payload in my Azure Function and can take a decision?

I am using Java as a programming language for the same.


If you are using X.509 based authentication, your Azure Function is getting the actual certificate as part of the request (in the clientCertificate field).

Therefore, you may want to use custom fields in your certificate that you can read in your function, and then allocate your IoT Hub of choice based on their contents.

Another option, and probably more elegant as having custom fields in your certificate might expose information that’d better remain private, would be to maintain the mappings between the registrationId, customerId, customerId, etc. in a separate store, which you can query in your Azure Function.

Source: stackoverflow