2

In Azure Device Provisioning Service

  • when using a custom allocation policy,
  • with '--reprovision-policy reprovisionandmigratedata'

is it possible to migrate the device twin data when the changing hubs and change some of the values in the twin?

From experiments initialTwin is ignored when moving between hubs (as opposed to registered for the first time) which is not that unexpected.

Example

Let's say that device d1 is provisioned to hub1 and its desired is

"desired" : {
  "a": 1
} 

Some time later d1 reprovisions and the allocation function is executed and it will move the device to hub2. I need the new desired to be:

"desired" : {
  "a": 2
} 
tymtam
  • 31,798
  • 8
  • 86
  • 126
  • According to [IoT Hub Device reprovisioning concepts](https://learn.microsoft.com/en-us/azure/iot-dps/concepts-device-reprovision) , when selecting 'Re-provision and migrate data', we move "device state updated on the previous IoT hub over to the new IoT hub". If you want to keep the initial configuration you need to select 'Re-provision and reset to initial config' . – asergaz Feb 23 '22 at 15:00
  • @asergaz I need to keep the existing twin and add a new value. – tymtam Feb 24 '22 at 04:52
  • Can you share the device twin JSON file before and after reprovisioning? Not sure I understood the difference between the two. Are you changing reported and desired properties? Tags? – asergaz Feb 25 '22 at 17:09
  • 1
    @asergaz The difference is 1st provisioning vs reprovisioning. – tymtam Feb 27 '22 at 22:53

1 Answers1

0

I have confirmed that when "re-provision and migrate data" the initialTwin will be ignored and that is by design.

An alternative is to query the latest twin from the device as part of custom allocation, add the new property and send it to DPS while choosing "re-provision and reset to initial config".

asergaz
  • 996
  • 5
  • 17