I am trying to update the Module twin of an edge device. I can now retrieve the Device Twin for the module, but I cannot save the updated Desired properties back into the IoT Hub.
var moduleTwin = await registryManager.GetTwinAsync("DeviceId", "ModuleId");
moduleTwin.Properties.Desired["key"] = "value";
var updatedTwin = await registryManager.UpdateTwinAsync("DeviceId", moduleTwin, moduleTwin.ETag)
When this runs, I get the following exception
Where "DeviceId" is the value obscured in red.
I have tried using the device's ETag, but that just updated the device's twin and I have tried using the ModuleId rather then DeviceId and that raises a DeviceNotFoundException.
How do I update the ModuleTwin here?