We are currently facing an issue with our configured Event Hub, which is set up to listen for changes in the IoT Hub device twin. Our problem arises when we update the reported section of the device twin. We have noticed that the tags associated with the device twin are not included in the payload message received by the Event Hub, though the message enrichment for the same tag value is configured in the iothub under message routes. However, when we update the desired property of the device twin, the tags are correctly included in the message sent to the Event Hub.
I have created an IoT device and specified some tags in the Identity Twin of the device.
"tags": { "deviceId": "", "deviceLocation": { "latLong": [], "city": "" }, "tenantCode": "" },
I have defined message enrichments and routes in IoT Hub based on the tags that I've added. Below is the sample response message we got from the eventhub when we updated the reported session of the device twin.
{"version":7,"properties":{"reported":{"deviceInformation":{"ProcessorManufacturer":"STMicroelectronics","manufacturer":"MXCHIP","processArchitecture":"Arm Cortex M4","osName":"Azure RTOS","totalStorage":1234,"model":"AZ3166","swVersion":"1.0.0","totalMemory":128},"$metadata":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z","deviceInformation":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z","ProcessorManufacturer":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"manufacturer":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"processArchitecture":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"osName":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"totalStorage":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"model":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"swVersion":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"},"totalMemory":{"$lastUpdated":"2023-06-19T12:55:31.9240242Z"}}},"$version":3}}}.
We kindly request your assistance in resolving this matter
The payload message received by the Event Hub when the reported property is updated, we would expect the tags associated with the device twin to be included in the message sent to the Event Hub, along with the changes made in the reported section.
From the doc Understand and use device twins in IoT Hub:
On the other side, such as a service facing side, the tags are there visible and manageable, so we can see them in the payload (with the desired properties), when there are changed.
Note, that using the enrich messages feature, we can pass a value of the tags to the user (app) properties, but not into the payload message, for that requirement, the azure function will be needed.