Azure / iot-hub-device-update

Device Update for IoT Hub agent
MIT License
51 stars 36 forks source link

DeviceManagementClient.GetDeviceModuleAsync does not return the ExtendedResultCode #624

Closed mahdighorbanpourptw closed 4 weeks ago

mahdighorbanpourptw commented 1 month ago

Library name and version

Azure.IoT.DeviceUpdate 1.0.0

Describe the bug

Hi, I am using Azure.IoT.DeviceUpdate version 1.0.0 in my C# project. I am using Azure device update service (Agent) on Ubuntu 22.04 and assigned an update to my device. The update is failing and I checked the deviceUpdateAgent logs under /var/log/adu. In the log files the extendedResultCode is written like following:

2024-04-17T13:20:21.7523Z 81202[87935] [D] [ADUC_D2C_Message_SendAsync:526] ==== MULTI-LINE LOG BEGIN ====
Queueing message (t:0, c:0x80004680, m:{"deviceUpdate":{"__t":"c","agent":{"lastInstallResult":{"stepResults":{"step_0":{"resultCode":0,"extendedResultCodes":"30501028","resultDetails":"InstallUpdate: installation failed."}},"resultCode":0,"extendedResultCodes":"30501028,A0000FFF","resultDetails":"InstallUpdate: installation failed."},"state":0,"workflow":{"action":3,"id":"deployment-xxx"}}}})2024-04-17T13:20:21.7523Z 81202[87935] [D] [ADUC_D2C_Message_SendAsync:526] ==== MULTI-LINE LOG END ====

At the same time, on the IotHub->Edge ->MyDevice -> Modules -> IoTHubDeviceUpdate -> ModuleIdentityTwin -> Reportedproperties the same extendedResultCode is there!

 "deviceUpdate": {
                "__t": "c",
                "agent": {
                    "deviceProperties": {
                        "manufacturer": "xxx",
                        "model": "xxx",
                        "contractModelId": "dtmi:azure:iot:deviceUpdateContractModel;3",
                        "aduVer": "DU;agent/1.1.0"
                    },
                    "compatPropertyNames": "manufacturer,model",
                    "lastInstallResult": {
                        "resultCode": 0,
                        "extendedResultCodes": "30501028,A0000FFF",
                        "stepResults": {
                            "step_0": {
                                "resultCode": 0,
                                "extendedResultCodes": "30501028",
                                "resultDetails": "InstallUpdate: installation failed."
                            }
                        },
                        "resultDetails": "InstallUpdate: installation failed."
                    },
                    "state": 0,
                    "workflow": {
                        "action": 3,
                        "id": "deployment-ptwedge-0-77-151-0416071220"
                    }
                },

However, the extendedResultCode is always null when I use the following method in C# and also on the Azure-Portal.

response = await _deviceManagementClient.GetDeviceModuleAsync(deviceId, "IoTHubDeviceUpdate");
 var json = response.Content.ToString();

image

Expected behavior

It should return the reported extendedResultCodes in the json response

Actual behavior

extendedResultCode is always null

Reproduction Steps

Create an update with script step. make the script fail with a specific non-zero exit code assign the update to your device

Environment

Ubuntu 22.04 aziot-edge: 1.4.33-1 deviceupdate-agent: 1.1.0

This is a duplicate of https://github.com/Azure/azure-sdk-for-net/issues/43469

josephmsft commented 1 month ago

This may be a bug on us correctly surfacing the value from the twin. I have filed a bug internally to investigate and address this.

josephmsft commented 4 weeks ago

This should be fixed now, you should no longer see the incorrect behavior

josephmsft commented 4 weeks ago

Issue should be fixed now