Azure / Azure/azure-iot-sdk-csharp

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

Open
#3,481 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
477
Forks
492
Avg merge
9h 55m
Merged PRs (30d)
2

Description

# 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 moduleTwins = new List();
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"}'

Contributor guide

Open the contributing guide

Research direction

Start with the provided GetTwinAsync, ConfigureModuleTwins, and UpdateTwins2Async sequence and reproduce it using the stated SDK version and .NET 8 environment. Check how UpdateTwins2Async handles multiple module twins sharing one device ID, then compare the observed DeviceDefinedMultipleTimes response with the expected API behavior; done means establishing the cause and documenting or implementing the supported resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.