Module twin $metadata $lastUpdated property is updated for every desired property
See original GitHub issueExpected Behavior
The module twin provides metadata for desired properties including a $lastUpdated
property which should be updated when the corresponding desired property is updated.
Current Behavior
Updating any property results in the $lastUpdated
property being updated for EVERY existing desired property, not just the one that was actually updated.
Steps to Reproduce
- Create 2 desired properties on a module in the Azure portal and click save.
- Update the first property to a new value and click save
- Observe the desired property metadata
Expected:
$lastUpdated
for the first property should be updated with a new timestamp, while the second property metadata does not change.
Actual: Both values are updated to the same timestamp.
Additional Information
This also happens from the C# SDK RegistryManager
from Microsoft.Azure.Devices
(v1.17.3)
Example:
var registryClient = RegistryManager.CreateFromConnectionString("connection-string");
var twin = await registryClient.GetTwinAsync(deviceId, moduleId);
twin.Properties.Desired[key] = value;
await registryClient.UpdateTwinAsync(deviceId, moduleId, twin, twin.ETag);
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Understand and use module twins in IoT Hub - Azure
Module twin metadata. IoT Hub maintains the timestamp of the last update for each JSON object in module twin desired and reported properties....
Read more >Understand and use device twins in IoT Hub - Azure
Device twin metadata. IoT Hub maintains the timestamp of the last update for each JSON object in device twin desired and reported properties....
Read more >Azure IoT Hub - How to get what's newer of desired vs ...
shows a workaround for missing a CASE statement: query string to get the desired property as the lastUpdated: querystring = $"SELECT devices.
Read more >Adding local persisted state to IoT Edge modules using ...
Once the updated values of changed desired properties are arriving at a device, a notification method on the device is triggered to handle...
Read more >Twin (IoT Hub Java Device Client 2.1.4 API)
Each entity in the collections can contain a associated TwinMetadata . ... Service and contains information about the last updated date time, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When you update desired properties (or tags), please call UpdateTwin by passing properties that you want to update only; otherwise, we will update all properties passed in the call. For example,
var registryClient = RegistryManager.CreateFromConnectionString(“connection-string”); var twin = await registryClient.GetTwinAsync(deviceId, moduleId);
var twinToUpdate = new Twin(); twinToUpdate.DeviceId = twin.DeviceId; twinToUpdate.ModuleId = twin.ModuleId; twinToUpdate.Properties.Desired[key] = value; await registryClient.UpdateTwinAsync(deviceId, moduleId, twinToUpdate, twin.ETag);
Thanks @isyama. I’d seen those, and just wondered if there were any specific implementation examples (C# for instance). If not, it would be great to see those, but I’m happy to close the ticket.