I’m trying to make an update using Azure Device Update on ubuntu 22.04. When my update is of type apt (microsoft/apt:1) it works fine.
But when I try to run a script (microsoft/script:1) i’m getting error from ADU: 810549253 (0x30500005).
ADUC_ERC_SCRIPT_HANDLER_MISSING_SCRIPTFILENAME_PROPERTY MAKE_ADUC_EXTENDEDRESULTCODE_FOR_COMPONENT_ADUC_CONTENT_HANDLER_SCRIPT(5)
List of errors: result.h
Here the script that I want to run:
script_test.sh:
#!/bin/bash
# Create a directory
mkdir -p /home/azureuser/this_was_create_by_adu
# Create a text file with specified content inside the directory
echo "this file was generated by adu" > /home/azureuser/this_was_create_by_adu/generated_file.txt
# Confirmation message
echo "Directory and file have been created successfully."
The import manifest:
script_test.importmanifest.json:
{
"updateId": {
"name": "script",
"provider": "me",
"version": "7.0.0"
},
"compatibility": [
{
"manufacturer": "hp",
"model": "elite"
}
],
"createdDateTime": "2024-10-23T09:33:11Z",
"files": [
{
"filename": "script_test.sh",
"hashes": {
"sha256": "lHKs3UsbWJAE3Svz3KwPCWibEofSPisKfB2rsbyIM4E="
},
"sizeInBytes": 328
}
],
"instructions": {
"steps": [
{
"files": [
"script_test.sh"
],
"handler": "microsoft/script:1",
"handlerProperties": {
"installedCriteria": "1.0",
},
"type": "inline"
}
]
},
"manifestVersion": "5.0"
}
The log error:
2024-11-05T15:39:52.8793Z 5742[7981] [I] Try to load a handler for current update manifest version 5 (handler: ‘microsoft/update-manifest:5’) [GetUpdateManifestHandler:114] 2024-11-05T15:39:52.8793Z 5742[7981] [I] Loading handler for ‘microsoft/update-manifest:5’. [LoadUpdateContentHandlerExtension:208] 2024-11-05T15:39:52.8794Z 5742[7981] [I] Loading extension ‘microsoft/update-manifest:5’. Reg file : /var/lib/adu/extensions/update_content_handlers/microsoft_update-manifest_5/content_handler.json [LoadExtensionLibrary:85] 2024-11-05T15:39:52.8794Z 5742[7981] [D] Determining contract version for ‘microsoft/update-manifest:5’. [LoadUpdateContentHandlerExtension:303] 2024-11-05T15:39:52.8794Z 5742[7981] [D] Got 1.0 contract version for ‘microsoft/update-manifest:5’ handler [LoadUpdateContentHandlerExtension:331] 2024-11-05T15:39:52.8794Z 5742[7981] [D] Caching new handler for ‘microsoft/update-manifest:5’. [LoadUpdateContentHandlerExtension:340] 2024-11-05T15:39:52.8797Z 5742[7981] [I] Action ‘Download’ complete. Result: 0 (failed), 810549253 (0x30500005) [ADUC_Workflow_WorkCompletionCallback:890] 2024-11-05T15:39:52.8797Z 5742[7981] [I] WorkCompletionCallback: Download failed. Going to state Failed [ADUC_Workflow_WorkCompletionCallback:1016] 2024-11-05T15:39:52.8797Z 5742[7981] [I] Setting UpdateState to Failed [ADUC_Workflow_SetUpdateStateHelper:1088]
2024-11-05T15:39:52.8797Z 5742[7981] [D] [ADUC_D2C_Message_SendAsync:526] ==== MULTI-LINE LOG BEGIN ====
Queueing message (t:0, c:0x64006e50, m:{"deviceUpdate":{"__t":"c","agent":{"lastInstallResult":{"stepResults":{"step_0":{"resultCode":0,"extendedResultCodes":"00000000","resultDetails":null}},"resultCode":0,"extendedResultCodes":"30500005,A0000FFF","resultDetails":""},"state":255,"workflow":{"action":3,"id":"aebe0066-67ba-4d78-a247-2656d91dd7c8"}}}})2024-11-05T15:39:52.8797Z 5742[7981] [D] [ADUC_D2C_Message_SendAsync:526] ==== MULTI-LINE LOG END ====
2024-11-05T15:39:52.8815Z 5742[7981] [I] Workflow is Complete. [ADUC_Workflow_AutoTransitionWorkflow:758] 2024-11-05T15:39:53.2803Z 5742[5742] [D] context:0xb6b015a0 [DefaultIoTHubSendReportedStateCompletedCallback:205] 2024-11-05T15:39:53.2803Z 5742[5742] [D] D2C message processed successfully (t:0, r:0, content:0xb8465da0 ) [DefaultIoTHubSendReportedStateCompletedCallback:233] 2024-11-05T15:39:53.2803Z 5742[5742] [D] Send message completed (status:3) [OnUpdateResultD2CMessageCompleted:64] 2024-11-05T15:39:53.2804Z 5742[5742] [D] context:0xb6b01640 [DefaultIoTHubSendReportedStateCompletedCallback:205] 2024-11-05T15:39:53.2804Z 5742[5742] [D] D2C message processed successfully (t:1, r:0, content:0xb843b8c0 ) [DefaultIoTHubSendReportedStateCompletedCallback:233] 2024-11-05T15:39:53.2804Z 5742[5742] [D] Send message completed (status:3) [OnUpdateResultD2CMessageCompleted:64] 2024-11-05T15:39:53.2804Z 5742[5742] [D] Sending D2C message (t:0, retries:0). [ProcessMessage:390]
2024-11-05T15:39:53.2804Z 5742[5742] [D] [ADUC_D2C_Default_Message_Transport_Function:580] ==== MULTI-LINE LOG BEGIN ====
Sending D2C message:
{"deviceUpdate":{"__t":"c","agent":{"lastInstallResult":{"stepResults":{"step_0":{"resultCode":0,"extendedResultCodes":"00000000","resultDetails":null}},"resultCode":0,"extendedResultCodes":"30500005,A0000FFF","resultDetails":""},"state":255,"workflow":{"action":3,"id":"aebe0066-67ba-4d78-a247-2656d91dd7c8"}}}}2024-11-05T15:39:53.2804Z 5742[5742] [D] [ADUC_D2C_Default_Message_Transport_Function:580] ==== MULTI-LINE LOG END ====
2
Answers
After restarting the Virtual Machine that I was using for testing, I encountered a different error:
"The install script doesn't create a result file '/var/lib/adu/downloads/aebe0066-67ba-4d78-a247-2656d91dd7c8/action_download_aduc_result.json'."
According to the responses on the issue I opened on GitHub, I noticed that I wasn't writing the result to the result file, which is mandatory
https://github.com/Azure/iot-hub-device-update/issues/667.
Following the documentation and the example script I rewrote the script and the import manifest and it worked properly:
script_test.importmanifest.json:
script_test.sh