使用 Azure CLI 處理計劃性維護通知

適用於: ✔️ Linux VM ✔️ Windows VM ✔️ 彈性擴展集 ✔️ 統一擴展集

您可以使用 CLI 來檢視 VM 何時排程維護。 您可以從 az vm get-instance-view 取得計劃性維護資訊。

只在有預定進行的維修作業時,才會傳回維修資訊。

az vm get-instance-view -n myVM -g myResourceGroup --query instanceView.maintenanceRedeployStatus

輸出

      "maintenanceRedeployStatus": {
      "additionalProperties": {},
      "isCustomerInitiatedMaintenanceAllowed": true,
      "lastOperationMessage": null,
      "lastOperationResultCode": "None",
      "maintenanceWindowEndTime": "2018-06-04T16:30:00+00:00",
      "maintenanceWindowStartTime": "2018-05-21T16:30:00+00:00",
      "preMaintenanceWindowEndTime": "2018-05-19T12:30:00+00:00",
      "preMaintenanceWindowStartTime": "2018-05-14T12:30:00+00:00"

啟動維護

如果 IsCustomerInitiatedMaintenanceAllowed 設定為 true,下列呼叫將會在 VM 上啟動維護。

az vm perform-maintenance -g myResourceGroup -n myVM 

傳統部署

重要

透過傳統部署模型建立的 VM 將於 2023 年 9 月 1 日淘汰。

如果您使用來自 Azure 服務管理的 IaaS 資源,請在 2023 年 9 月 1 日前完成移轉。 我們鼓勵您及早切換,以利用 Azure Resource Manager 的許多功能增強功能。

如需詳細資訊,請參閱請於 2023 年 9 月 1 日之前將您的 IaaS 資源遷移至 Azure Resource Manager

如果您仍有使用傳統部署模型部署的舊版 VM,可以使用 Azure 傳統 CLI 查詢 VM 並起始維護。

請鍵入下列項目,以確認您使用傳統 VM 的模式正確:

azure config mode asm

若要取得名為 myVM 的 VM 維護狀態,請鍵入:

azure vm show myVM 

若要開始維護 myService 服務和 myDeployment 部署中名為 myVM 的傳統虛擬機器,請鍵入:

azure compute virtual-machine initiate-maintenance --service-name myService --name myDeployment --virtual-machine-name myVM

下一步

您也可以使用 Azure PowerShell入口網站來處理計劃性維護。