您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

从 runbook 启用“更新管理”Enable Update Management from a runbook

本文介绍如何使用 runbook 为环境中的 VM 启用更新管理功能。This article describes how you can use a runbook to enable the Update Management feature for VMs in your environment. 若要大规模启用 Azure VM,必须使用更新管理启用现有 VM。To enable Azure VMs at scale, you must enable an existing VM using Update Management.

备注

在启用更新管理时,只有某些区域支持链接 Log Analytics 工作区和自动化帐户。When enabling Update Management, only certain regions are supported for linking a Log Analytics workspace and an Automation account. 有关支持的映射对的列表,请参阅自动化帐户和 Log Analytics 工作区的区域映射For a list of the supported mapping pairs, see Region mapping for Automation account and Log Analytics workspace.

先决条件Prerequisites

登录 AzureSign in to Azure

登录到 Azure 门户Sign in to the Azure portal.

启用更新管理Enable Update Management

  1. 在自动化帐户中,选择“更新管理”下的“更新管理”。In your Automation account, select Update Management under Update Management.

  2. 选择 Log Analytics 工作区,然后单击“启用”。Select the Log Analytics workspace, then click Enable. 启用更新管理时,将显示蓝色横幅。While Update Management is being enabled, a blue banner is shown.

    启用更新管理

选择要管理的 Azure VMSelect Azure VM to manage

启用更新管理后,可以添加 Azure VM 以接收更新。With Update Management enabled, you can add an Azure VM to receive updates.

  1. 从自动化帐户,选择“更新管理”下的“更新管理”。From your Automation account, select Update management under Update management.

  2. 选择“添加 Azure VM”以添加你的 VM。Select Add Azure VMs to add your VM.

  3. 从列表中选择 VM,然后单击“启用”以设置 VM 进行更新。Choose the VM from the list and click Enable to set up the VM for updates.

    为 VM 启用更新管理

    备注

    如果在完成更新管理设置之前尝试启用另一个功能,则会收到以下消息:Installation of another solution is in progress on this or a different virtual machine. When that installation completes the Enable button is enabled, and you can request installation of the solution on this virtual machine.If you try to enable another feature before setup of Update Management has completed, you receive this message: Installation of another solution is in progress on this or a different virtual machine. When that installation completes the Enable button is enabled, and you can request installation of the solution on this virtual machine.

安装和更新模块Install and update modules

必须更新到最新的 Azure 模块并导入 Az.OperationalInsights 模块才能成功为 VM 启用更新管理。It's required to update to the latest Azure modules and import the Az.OperationalInsights module to successfully enable Update Management for your VMs.

  1. 在你的自动化帐户中的“共享资源”下选择“模块” 。In your Automation account, select Modules under Shared Resources.

  2. 选择“更新 Azure 模块”以更新到最新版本的 Azure 模块。Select Update Azure Modules to update the Azure modules to the latest version.

  3. 单击“是”,将所有现有 Azure 模块更新到最新版本。Click Yes to update all existing Azure modules to the latest version.

    更新模块

  4. 返回“共享资源”下的“模块” 。Return to Modules under Shared Resources.

  5. 选择“浏览库”以打开模块库。Select Browse gallery to open the module gallery.

  6. 搜索 Az.OperationalInsights 并将此模块导入到自动化帐户中。Search for Az.OperationalInsights and import this module into your Automation account.

    导入 OperationalInsights 模块

导入 runbook 以启用更新管理Import a runbook to enable Update Management

  1. 在你的自动化帐户中的“流程自动化”下选择“Runbook”。In your Automation account, select Runbooks under Process Automation.

  2. 选择“浏览库”。Select Browse gallery.

  3. 搜索 update and change trackingSearch for update and change tracking.

  4. 选择 Runbook,然后在“查看源”页上单击“导入”。Select the runbook and click Import on the View Source page.

  5. 单击“确定”,将 Runbook 导入到自动化帐户中。Click OK to import the runbook into the Automation account.

    导入 Runbook 进行设置

  6. 在“Runbook”页上单击“编辑”,然后选择“发布”。On the Runbook page, click Edit, then select Publish.

  7. 在“发布 Runbook”窗格中,单击“是”以发布 Runbook。On the Publish Runbook pane, click Yes to publish the runbook.

启动 RunbookStart the runbook

必须已为 Azure VM 启用了更新管理,才能启动此 runbook。You must have enabled Update Management for an Azure VM to start this runbook. 它需要为参数启用了该功能的现有 VM 和资源组。It requires an existing VM and resource group with the feature enabled for parameters.

  1. 打开“Enable-MultipleSolution”Runbook。Open the Enable-MultipleSolution runbook.

    多个解决方案 Runbook

  2. 单击启动按钮,在以下字段中输入参数值:Click the start button and enter parameter values in the following fields:

    • VMNAME - 要添加到更新管理中的现有 VM 的名称。VMNAME - The name of an existing VM to add to Update Management. 将此字段留空可添加资源组中的所有 VM。Leave this field blank to add all VMs in the resource group.
    • VMRESOURCEGROUP - 要启用的 VM 的资源组的名称。VMRESOURCEGROUP - The name of the resource group for the VMs to enable.
    • SUBSCRIPTIONID - 要启用的新 VM 的订阅 ID。SUBSCRIPTIONID - The subscription ID of the new VM to enable. 将此字段留空可使用工作区的订阅。Leave this field blank to use the subscription of the workspace. 使用不同的订阅 ID 时,请添加自动化帐户的运行方式帐户作为订阅的参与者。When you use a different subscription ID, add the Run As account for your Automation account as a contributor for the subscription.
    • ALREADYONBOARDEDVM - 已为更新手动启用的 VM 的名称。ALREADYONBOARDEDVM - The name of the VM that is already manually enabled for updates.
    • ALREADYONBOARDEDVMRESOURCEGROUP - VM 所属的资源组的名称。ALREADYONBOARDEDVMRESOURCEGROUP - The name of the resource group to which the VM belongs.
    • SOLUTIONTYPE - 输入“更新”。SOLUTIONTYPE - Enter Updates.

    Enable-MultipleSolution Runbook 参数

  3. 选择“确定”启动 Runbook 作业。Select OK to start the runbook job.

  4. 从 "作业" 页中监视 runbook 作业和任何错误的进度。Monitor progress of the runbook job and any errors from the Jobs page.

后续步骤Next steps