question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module twin $metadata $lastUpdated property is updated for every desired property

See original GitHub issue

Expected 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

  1. Create 2 desired properties on a module in the Azure portal and click save.
  2. Update the first property to a new value and click save
  3. 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:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
isyamacommented, May 25, 2019

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);

1reaction
AMCN41Rcommented, Jun 3, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found