Search code examples
azureservicedeviceiotprovisioning

Can you re-provision a device through Azure Device Provisioning Service using MQTT directly?


I am designing a solution for connected devices and have a requirement to re-provision a device before sending a message to ensure it is always connected to the nearest IoT Hub (based on latency).

Based on the Microsoft documentation, it is possible to register a device using MQTT by publishing a message to the DPS. However, is it possible to re-provision a device with MQTT?

https://learn.microsoft.com/en-us/azure/iot-dps/iot-dps-mqtt-support

Also, when registering a device for the first time via MQTT, is there a topic to subscribe to obtain the connection of the IoT Hub that DPS assigned the device?


Solution

  • Yes. The same API (Register message) triggers re-provisioning. The device is unaware as to whether it is being provisioned or re-provisioned.

    The results of provisioning (or re-provisioning) including the name of the IotHub and the corresponding credential are published in the DeviceRegistrationResult object. This object is part of the RegistrationOperationStatus object returned in response to the get-operation-status operation.