Skip to content

[Bug Report] UpdateTwins2Async throws error when updating module twins with the same device ID #3481

@dnguyen-0

Description

@dnguyen-0

Context

  • OS, version, SKU and CPU architecture used: Windows 11 Desktop x64
  • Application's .NET Target Framework : .net 8.0
  • Device: laptop
  • SDK version used: Microsoft.Azure.Devices 1.40.0

Description of the issue

I have a list of modules in an IoT hub Edge device. All the modules belong to the same edge device and they will have the same device ID. Invoking UpdateTwins2Async method throws an exception specified in the section below.
Last year there was no such problem. What could be the reason and what should I do? Thank you.

Code sample exhibiting the issue

List<Twin> moduleTwins = new List<Twin>();
foreach (var moduleId in moduleIds)
{
  var moduleTwin = await registryManager.GetTwinAsync(queriedDevice.Id, moduleId);
  moduleTwins.Add(moduleTwin);
}
ConfigureModuleTwins(moduleTwins); // Adapt modules' twins
await registryManager.UpdateTwins2Async(moduleTwins, true);

Console log of the issue

'{"Message":"ErrorCode:DeviceDefinedMultipleTimes;DeviceDefinedMultipleTimes, device ID FITS4U_GW_DNGUYEN","ExceptionMessage":"Tracking ID:4D2CE505AD7945E4B55EF03952FA8549-G2:-TimeStamp:2025-01-08T19:28:00.672603626Z"}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions