多步驟排序執行
IoT 中樞 Azure 裝置更新中的多步驟排序執行,可讓您在部署無線更新時執行預安裝及張貼安裝工作。 這項功能是裝置更新指令清單架構第 4 版的一部分。 如需詳細資訊,請參閱 裝置更新指令清單。
多步驟排序執行可以有兩種類型的步驟: 內嵌步驟 和 參考步驟。 內嵌步驟是執行程式碼且為預設類型的指令。 參考步驟是包含另一個更新標識碼的步驟。
父代更新和子系更新
當更新指令清單參考另一個更新指令清單時,最上層指令清單稱為 父更新,而參考步驟中指定的指令清單稱為 子更新。 子更新不能包含任何參考步驟,只有內嵌步驟。 裝置更新會在匯入時驗證此限制,如果不符合更新,就會失敗。
父代更新中的內嵌步驟
裝置更新代理程式會將父更新中指定的內嵌步驟套用至主機裝置。 ADUC_WorkflowData
傳遞至步驟處理程序的物件,也稱為更新內容處理程式,不包含任何Selected Components
數據。 這個步驟類型的處理程序不應該是 Component-Aware
處理程式。
裝置更新代理程式的步驟內容處理程式會 IsInstalled
為每個步驟套用驗證邏輯。 步驟處理程式會檢查更新是否已安裝,方法是檢查是否 IsInstalled()
傳回結果碼 900
或 true,並使用此結果來判斷是否要執行步驟。 為了避免重新安裝裝置上的更新,如果已安裝更新,裝置更新代理程式會略過未來的步驟。
若要報告更新結果,請將步驟處理程式執行 ADUC_Result
的結果寫入至選項中指定的所需結果檔中的 --result-file
結構。 根據執行的結果,傳回 0
成功並傳回 -1
或 0xFF
嚴重錯誤。
如需詳細資訊,請參閱 步驟處理程式 和 如何實作自定義元件感知內容處理程式。
父代更新中的參考步驟
裝置更新代理程式會將父更新中指定的參考步驟套用至主機裝置上或連線到的元件。 處理參考步驟時,步驟處理程式會下載步驟中指定的中斷連結更新指令清單檔案,並驗證檔案完整性。
然後,步驟處理程式會剖析子更新指令清單並建立 ADUC_Workflow
物件,也稱為子工作流程數據,方法是結合父更新指令清單中的數據和父更新指令清單中的檔案 URL 資訊。 這個子工作流程資料的屬性 level
設定為 1
。
範例
下列範例更新指令清單有一個內嵌步驟:
{
"updateId": {...},
"isDeployable": true,
"compatibility": [
{
"manufacturer": "du-device",
"model": "e2e-test"
}
],
"instructions": {
"steps": [
{
"description": "Example APT update that installs libcurl4-doc on a host device.",
"handler": "microsoft/apt:1",
"files": [
"apt-manifest-1.0.json"
],
"handlerProperties": {
"installedCriteria": "apt-update-test-1.0"
}
}
]
},
"manifestVersion": "4.0",
"importedDateTime": "2021-11-16T14:54:55.8858676Z",
"createdDateTime": "2021-11-16T14:50:47.3511877Z"
}
下列範例更新指令清單有兩個內嵌步驟:
{
"updateId": {...},
"isDeployable": true,
"compatibility": [
{
"manufacturer": "du-device",
"model": "e2e-test"
}
],
"instructions": {
"steps": [
{
"description": "Install libcurl4-doc on host device",
"handler": "microsoft/apt:1",
"files": [
"apt-manifest-1.0.json"
],
"handlerProperties": {
"installedCriteria": "apt-update-test-2.2"
}
},
{
"description": "Install tree on host device",
"handler": "microsoft/apt:1",
"files": [
"apt-manifest-tree-1.0.json"
],
"handlerProperties": {
"installedCriteria": "apt-update-test-tree-2.2"
}
}
]
},
"manifestVersion": "4.0",
"importedDateTime": "2021-11-16T20:21:33.6514738Z",
"createdDateTime": "2021-11-16T20:19:29.4019035Z"
}
下列父更新指令清單有一個參考步驟,參考子更新:
{
"updateId": {...},
"isDeployable": true,
"compatibility": [
{
"manufacturer": "du-device",
"model": "e2e-test"
}
],
"instructions": {
"steps": [
{
"type": "reference",
"description": "Cameras Firmware Update",
"updateId": {
"provider": "contoso",
"name": "virtual-camera",
"version": "1.2"
}
}
]
},
"manifestVersion": "4.0",
"importedDateTime": "2021-11-17T07:26:14.7484389Z",
"createdDateTime": "2021-11-17T07:22:10.6014567Z"
}
子更新包含內嵌步驟。
{
"updateId": {
"provider": "contoso",
"name": "virtual-camera",
"version": "1.2"
},
"isDeployable": false,
"compatibility": [
{
"group": "cameras"
}
],
"instructions": {
"steps": [
{
"description": "Cameras Update - preinstall step",
"handler": "microsoft/script:1",
"files": [
"contoso-camera-installscript.sh"
],
"handlerProperties": {
"scriptFileName": "contoso-camera-installscript.sh",
"arguments": "--pre-install-sim-success --component-name --component-name-val --component-group --component-group-val --component-prop path --component-prop-val path",
"installedCriteria": "contoso-virtual-camera-1.2-step-0"
}
},
{
"description": "Cameras Update - firmware installation (failure - missing file)",
"handler": "microsoft/script:1",
"files": [
"contoso-camera-installscript.sh",
"camera-firmware-1.1.json"
],
"handlerProperties": {
"scriptFileName": "missing-contoso-camera-installscript.sh",
"arguments": "--firmware-file camera-firmware-1.1.json --component-name --component-name-val --component-group --component-group-val --component-prop path --component-prop-val path",
"installedCriteria": "contoso-virtual-camera-1.2-step-1"
}
},
{
"description": "Cameras Update - postinstall step",
"handler": "microsoft/script:1",
"files": [
"contoso-camera-installscript.sh"
],
"handlerProperties": {
"scriptFileName": "contoso-camera-installscript.sh",
"arguments": "--post-install-sim-success --component-name --component-name-val --component-group --component-group-val --component-prop path --component-prop-val path",
"installedCriteria": "contoso-virtual-camera-1.2-step-2"
}
}
]
},
"referencedBy": [
{
"provider": "DU-Client-Eng",
"name": "MSOE-Update-Demo",
"version": "3.1"
}
],
"manifestVersion": "4.0",
"importedDateTime": "2021-11-17T07:26:14.7376536Z",
"createdDateTime": "2021-11-17T07:22:09.2232968Z",
"etag": "\"ad7a553d-24a8-492b-9885-9af424d44d58\""
}
注意
如果您使用 installedCriteria
來判斷是否應該執行步驟,您應該在更新指令清單中為每個步驟提供不同的 installedCriteria
值。
中斷連結更新資訊清單
為了避免部署失敗,因為 Azure IoT 中樞 對應項數據大小限制,Device Update 會將大型更新指令清單傳遞至裝置,作為稱為中斷連結更新指令清單的 JSON 數據檔。 當您將大型內容更新匯入裝置更新時,產生的更新指令清單會包含另 Detached Update Manifest
一個名為的承載檔案,其中包含完整的更新指令清單數據。
UpdateManifest
裝置或模組對應項中的 屬性包含中斷連結的更新指令清單檔案資訊。 處理 PnP PropertyChanged
事件時,裝置更新代理程式會自動下載中斷連結的更新指令清單檔案,並建立 ADUC_WorkflowData
包含完整更新指令清單數據的物件。