I am using Azure Device Twin in Azure IOT Hub and this issue is regarding the Device Twin behevior.
I have a DeviceTwin Structure as follows and I am using pure MQTT protocal to publish data into it.
The topic which I used to publish twin data is : $iothub/twin/PATCH/properties/reported/?$rid=c1a12cc8-4168-4e16-a1bb
The payload I sent is :
{
"deviceId": "34aa078e",
"properties": {
"desired": {
},
"reported": {
"notifications": {
"notification1": {
"primaryCode": "crprim1",
"statusChangeTimestamp": 1507115005615
},
"notification2": {
"primaryCode": "crprim2",
"statusChangeTimestamp": 1507117507027
}
},
"location": {
}
}
}
}
All the functionalities are working properly as documented in the DeviceTwin documentation but, I have one clarification to be cleared with respect to the behevior of this DeviceTwin.
When I send a message payload containing one new notification (named as notificaion3) through MQTT to update above DeviceTwin, it just add notification3 into the notifications object instead of just replacing entire notifications content with notification3.
MQTT payload which I sent:
{
"notifications": {
"notification3": {
"primaryCode": "crprim3",
"statusChangeTimestamp": 1607115005615
}
}
}
So I will be ultimately have following in the DeviceTwin structure,
{
"deviceId": "34aa078e",
"properties": {
"desired": {
},
"reported": {
"notifications": {
"notification1": {
"primaryCode": "crprim1",
"statusChangeTimestamp": 1507115005615
},
"notification2": {
"primaryCode": "crprim2",
"statusChangeTimestamp": 1507117507027
},
"notification3": {
"primaryCode": "crprim3",
"statusChangeTimestamp": 1607115005615
}
},
"location": {
}
}
}
}
Instead of following,
{
"deviceId": "34aa078e",
"properties": {
"desired": {
},
"reported": {
"notifications": {
"notification3": {
"primaryCode": "crprim3",
"statusChangeTimestamp": 1607115005615
}
},
"location": {
}
}
}
}
But Device Twin should contains the latest snapshot of a given device and it should not keep the previous data (with respect to a object level). Is this the usual behavior of Azure Device Twin ? Or is it some kind of a bug ?


