Azure Stack Hub 中的 VM 更新和管理自动化VM update and management automation in Azure Stack Hub

使用以下 Azure 自动化解决方案功能来管理使用 Azure Stack Hub 部署的 Windows 和 Linux 虚拟机 (VM):Use the following Azure Automation solution features to manage Windows and Linux virtual machines (VMs) that are deployed using Azure Stack Hub:

  • 更新管理 :借助更新管理解决方案,可以快速评估所有代理计算机上可用更新的状态,并管理为 Windows 和 Linux VM 安装所需更新的过程。Update Management: With the Update Management solution, you can quickly assess the status of available updates on all agent computers and manage the process of installing required updates for Windows and Linux VMs.

  • 用于 VM 的 Azure Monitor :用于 VM 的 Azure Monitor 可以大规模监视 Azure 与 Azure Stack Hub VM 和虚拟机规模集。Azure Monitor for VMs: Azure Monitor for VMs monitors your Azure and Azure Stack Hub VMs and virtual machine scale sets at scale. 它分析 Windows VM 和 Linux VM 的性能和运行状况,还监视它们的进程及其对其他资源和外部进程的依赖关系。It analyzes the performance and health of your Windows and Linux VMs and also monitors their processes and dependencies on other resources and external processes.

重要

这些解决方案与用于管理 Azure VM 的解决方案相同。These solutions are the same as the ones used to manage Azure VMs. 使用相同的工具,从相同的界面,通过相同的方式管理 Azure 和 Azure Stack Hub VM。Both Azure and Azure Stack Hub VMs are managed in the same way, from the same interface, using the same tools. 在 Azure Stack Hub 中使用更新管理和用于 VM 的 Azure Monitor 解决方案时,Azure Stack Hub VM 的价格还与 Azure VM 相同。The Azure Stack Hub VMs are also priced the same as Azure VMs when using the Update Management, and Azure Monitor for VMs solutions with Azure Stack Hub.

先决条件Prerequisites

使用这些功能更新和管理 Azure Stack Hub VM 之前,必须先满足一些先决条件。Several prerequisites must be met before using these features to update and manage Azure Stack Hub VMs. 其中包括 Azure 门户以及 Azure Stack Hub 管理门户中必须执行的步骤。These include steps that must be taken in the Azure portal and also the Azure Stack Hub administration portal.

在 Azure 门户中In the Azure portal

若要使用用于 VM 的 Azure Monitor、更新管理和适用于 Azure Stack Hub VM 的 Azure 自动化功能,首先需要在 Azure 中启用这些解决方案。To use the Azure Monitor for VMs, and Update Management Azure Automation features for Azure Stack Hub VMs, you first need to enable these solutions in Azure.

提示

如果已为 Azure VM 启用了这些功能,则可以使用预先存在的 LogAnalytics 工作区凭据。If you've already enabled these features for Azure VMs, you can use your pre-existing LogAnalytics Workspace credentials. 如果你已有要使用的 LogAnalytics 工作区 ID 和主密钥,请跳到下一节If you already have a LogAnalytics WorkspaceID and Primary Key that you want to use, skip ahead to the next section. 否则,请继续阅读本部分以创建新的 LogAnalytics 工作区和自动化帐户。Otherwise, continue in this section to create a new LogAnalytics Workspace and automation account.

启用这些解决方案的第一步是在 Azure 订阅中创建 LogAnalytics 工作区The first step in enabling these solutions is to create a LogAnalytics Workspace in your Azure subscription. Log Analytics 工作区是独特的 Azure Monitor 日志环境,其包含自身的数据存储库、数据源和解决方案。A Log Analytics workspace is a unique Azure Monitor logs environment with its own data repository, data sources, and solutions. 创建工作区后,请记下工作区 ID 和密钥。After you've created a workspace, note the WorkspaceID and Key. 若要查看此信息,请转到工作区边栏选项卡,单击“高级设置”,然后查看“工作区 ID”和“主密钥”值 。To view this information, go to the workspace blade, click on Advanced settings, and review the Workspace ID and Primary Key values.

接下来必须创建自动化帐户Next, you must create an Automation account. 自动化帐户是 Azure 自动化资源的容器。An Automation account is a container for your Azure Automation resources. 它提供一种方法来分离环境或进一步组织自动化工作流和资源。It provides a way to separate your environments or further organize your Automation workflows and resources. 创建自动化帐户后,需要启用更新管理功能。Once the Automation account is created, you need to enable the Update Management features. 若要启用该功能,请执行以下步骤:To enable each feature, follow these steps:

  1. 在 Azure 门户中,转到要使用的自动化帐户。In the Azure portal, go to the Automation Account that you want to use.

  2. 选择要启用的解决方案。Select the solution to enable.

  3. 使用“选择工作区...”下拉列表,选择要使用的 Log Analytics 工作区。Use the Select Workspace... drop-down list to select the Log Analytics workspace to use.

  4. 验证所有剩余的信息是否正确,然后单击“启用”以启用该解决方案。Verify that all remaining information is correct, and then click Enable to enable the solution.

  5. 重复步骤 2-4 以启用所有这三种解决方案。Repeat steps 2-4 to enable all three solutions.

    “诊断和解决问题”窗口显示了两个列表,其中突出显示了三个选项。“库存”处于选中状态。还有一个“Log Analytics 工作区”下拉列表和一个“启用”按钮。The "Diagnose and solve problems window" shows two lists with three options highlighted. Inventory is selected. There is also a "Log Analytics workspace" drop-down list, and an Enable button.

启用用于 VM 的 Azure MonitorEnable Azure Monitor for VMs

用于 VM 的 Azure Monitor 可以大规模监视 Azure VM 和虚拟机规模集。Azure Monitor for VMs monitors your Azure VMs and virtual machine scale sets at scale. 它分析 Windows VM 和 Linux VM 的性能和运行状况,还监视它们的进程及其对其他资源和外部进程的依赖关系。It analyzes the performance and health of your Windows and Linux VMs and also monitors their processes and dependencies on other resources and external processes.

作为一种解决方案,用于 VM 的 Azure Monitor 支持监视本地或其他云提供程序中托管的 VM 的性能和应用依赖关系。As a solution, Azure Monitor for VMs includes support for monitoring performance and app dependencies for VMs that are hosted on-premises or in another cloud provider. 三个主要功能提供深入的见解:Three key features deliver in-depth insight:

  1. Azure VM 的逻辑组件,将根据预先配置的运行状况条件对运行 Windows 和 Linux 的 Azure VM 进行度量,并在满足评估的条件时发出警报。Logical components of Azure VMs that run Windows and Linux that are measured against pre-configured health criteria, and they alert you when the evaluated condition is met.

  2. 预定义的趋势性能图表,显示来宾 VM 操作系统中的核心性能指标。Pre-defined trending performance charts that display core performance metrics from the guest VM operating system.

  3. 依赖关系映射,显示来自各种资源组和订阅的 VM 的互连组件。Dependency map that displays the interconnected components with the VM from various resource groups and subscriptions.

创建 Log Analytics 工作区后,在该工作区中启用性能计数器,用于在 Linux 和 Windows VM 上收集数据。After the Log Analytics Workspace is created, enable the performance counters in the workspace for collection on Linux and Windows VMs. 然后在工作区中安装并启用 ServiceMap 和 InfrastructureInsights 解决方案。Then, install and enable the ServiceMap and InfrastructureInsights solution in your workspace. 部署用于 VM 的 Azure Monitor 指南中介绍了此过程。The process is described in the Deploy Azure Monitor for VMs guide.

在 Azure Stack Hub 管理员门户In the Azure Stack Hub administrator portal

在 Azure 门户中启用 Azure 自动化解决方案之后,接下来需要以云管理员身份登录到 Azure Stack Hub 管理员门户,然后在 Azure Stack Hub 市场下载 Azure Monitor 更新和配置管理,以及适用于 Linux 的 Azure Monitor 更新和配置管理扩展 。After enabling the Azure Automation solutions in the Azure portal, you next need to sign in to the Azure Stack Hub administrator portal as a cloud admin and download the Azure Monitor, Update and Configuration Management and the Azure Monitor, Update and Configuration Management for Linux extension in the Azure Stack Hub Marketplace.

“主页 > 市场管理 > 从 Azure 添加 > Azure Monitor、更新和配置管理”对话框介绍了该扩展,并提供了“下载”按钮。

若要启用用于 VM 的 Azure Monitor 映射解决方案并深入了解网络依赖关系,请下载 Azure Monitor Dependency Agent:To enable the Azure Monitor for VMs Map solution and gain insights into the networking dependencies, download the Azure Monitor Dependency Agent:

“主页 > 市场管理 > 从 Azure 添加 > Azure Monitor Dependency Agent”对话框介绍了该扩展,并提供了“下载”按钮。

为 Azure Stack Hub VM 启用更新管理Enable Update Management for Azure Stack Hub VMs

按照以下步骤为 Azure Stack Hub VM 启用更新管理。Follow these steps to enable update management for Azure Stack Hub VMs.

  1. 登录到 Azure Stack Hub 用户门户。Sign in to the Azure Stack Hub user portal.

  2. 在 Azure Stack Hub 用户门户中,转到要为其启用这些解决方案的 VM 的“扩展”边栏选项卡,单击“+ 添加”,选择“Azure 更新和配置管理”扩展,然后单击“创建” :In the Azure Stack Hub user-portal, go to the Extensions blade of the VMs for which you want to enable these solutions, click + Add, select the Azure Update and Configuration Management extension, and then click Create:

    “Azure 更新和配置管理”对话框提供了解释信息、用于添加该扩展的“创建”按钮(已突出显示),以及指向详细信息的链接。The "Azure Update and Configuration Management" dialog box has explanatory information, a Create button (highlighted) to add the extension, and a link to more information.

  3. 提供之前创建的工作区 ID 和主密钥,将代理链接到 LogAnalytics 工作区。Provide the previously created WorkspaceID and Primary Key to link the agent with the LogAnalytics workspace. 然后单击“确定”部署扩展。Then click OK to deploy the extension.

    “安装扩展”对话框中包含用于提供 Azure WorkspaceID 和 WorkspaceKey 的文本框。The "Install extension" dialog box has text boxes for the Azure WorkspaceID and the WorkspaceKey.

  4. 更新管理文档中所述,需要为要管理的每个 VM 启用更新管理解决方案。As described in the Update Management documentation, you need to enable the Update Management solution for each VM that you want to manage. 若要为向工作区报告的所有 VM 启用解决方案,请选择“更新管理”,单击“管理计算机”,然后选择“在所有可用的和未来的计算机上启用”选项 。To enable the solution for all VMs reporting to the workspace, select Update management, click Manage machines, and then select the Enable on all available and future machines option.

    “管理计算机 - 更新管理”对话框显示了未启用更新管理的计算机。提供了三个启用选项,并且选中并突出显示了“在所有可用的和未来的计算机上启用”。有一个“启用”按钮。The Manage Machines - Update Management dialog box shows the machines that don't have Update Management enabled. Three enabling options are provided, and "enable on all available and future machines" is selected and highlighted. There is an Enable button.

    提示

    重复此步骤,为向工作区报告的 Azure Stack Hub VM 启用每个解决方案。Repeat this step to enable each solution for the Azure Stack Hub VMs that report to the workspace.

启用 Azure 更新和配置管理扩展后,每天对每个托管 VM 执行两次扫描。After the Azure Update and Configuration Management extension is enabled, a scan is done twice per day for each managed VM. 每隔 15 分钟就会调用一次 API 来查询上次更新时间,以确定状态是否已更改。The API is called every 15 minutes to query for the last update time to determine whether the status has changed. 如果状态已更改,则会启动符合性扫描。If the status has changed, a compliance scan is started.

扫描 VM 后,它们将显示在更新管理解决方案的 Azure 自动化帐户中:After the VMs are scanned, they'll appear in the Azure Automation account in the Update Management solution:

列出了已经过扫描的计算机。对于每一台,都提供符合性状态、平台、操作系统,以及缺少的关键更新的计数。总计数据中显示了需要关注的计算机的数量、缺少的更新的数量,等等。The scanned machines are listed. For each, the compliance status, platform, operating system, and count of critical missing updates is provided. There are totals showing how many machines need attention, how many are missing updates, and so on.

重要

可能需要 30 分钟到 6 小时,仪表板才会显示受托管计算机提供的已更新数据。It can take between 30 minutes and 6 hours for the dashboard to display updated data from managed computers.

Azure Stack Hub VM 现在可以与 Azure VM 一起包含在计划的更新部署中。The Azure Stack Hub VMs can now be included in scheduled update deployments together with Azure VMs.

创建更新部署计划Create an update deployment schedule

若要创建更新部署计划,必须使用 PowerShell cmdlet 或 Azure REST API 来传递计算机。To create an update deployment schedule, you must use a PowerShell cmdlet, or the Azure REST API, to pass the machines. 使用以下 PowerShell 示例来安排计算机。Use the following PowerShell example to get your machines scheduled. 可以将 New-AzAutomationSchedule cmdlet 与 ForUpdateConfiguration 参数配合使用创建一个计划。You can use the New-AzAutomationSchedule cmdlet with the ForUpdateConfiguration parameter to create a schedule. 然后,使用 New-AzAutomationSoftwareUpdateConfiguration cmdlet 并将 Azure Stack Hub 计算机传递到 NonAzureComputer 参数。Then, use the New-AzAutomationSoftwareUpdateConfiguration cmdlet and pass the Azure Stack Hub machines to the NonAzureComputer parameter. 若要运行此脚本,需要使用全局 Azure PowerShell Az 模块To run this script you will need to use the global Azure PowerShell Az module.

以下示例介绍如何执行此操作:The following example shows how to do this:

$nonAzurecomputers = @("server-01", "server-02")

$startTime = ([DateTime]::Now).AddMinutes(10)

$s = New-AzAutomationSchedule -ResourceGroupName mygroup -AutomationAccountName myaccount -Name myupdateconfig -Description test-OneTime -OneTime -StartTime $startTime -ForUpdateConfiguration

New-AzAutomationSoftwareUpdateConfiguration  -ResourceGroupName $rg -AutomationAccountName $aa -Schedule $s -Windows -AzureVMResourceId $azureVMIdsW -NonAzureComputer $nonAzurecomputers -Duration (New-TimeSpan -Hours 2) -IncludedUpdateClassification Security,UpdateRollup -ExcludedKbNumber KB01,KB02 -IncludedKbNumber KB100

启用在 Azure Stack Hub 上运行的用于 VM 的 Azure MonitorEnable Azure Monitor for VMs running on Azure Stack Hub

当 VM 具有“Azure Monitor 更新和配置管理”,并安装“Azure Monitor Dependency Agent”扩展后,它将开始在用于 VM 的 Azure Monitor 解决方案中报告数据 。Once the VM has the Azure Monitor, Update and Configuration Management, and the Azure Monitor Dependency Agent extensions installed, it will start reporting data in the Azure Monitor for VMs solution.

提示

Azure Monitor Dependency Agent 扩展不需要任何参数。The Azure Monitor Dependency Agent extension doesn't require any parameters. 用于 VM 的 Azure Monitor 映射依赖项代理本身不传输任何数据,它不需要对防火墙或端口做出任何更改。The Azure Monitor for VMs Map Dependency agent doesn't transmit any data itself, and it doesn't require any changes to firewalls or ports. 映射数据始终由 Log Analytics 代理直接传输到 Azure Monitor 服务;如果 IT 安全策略不允许网络中的计算机连接到 Internet,则通过 OMS 网关传输这些数据。The Map data is always transmitted by the Log Analytics agent to the Azure Monitor service, either directly or through the OMS Gateway if your IT security policies don't allow computers on the network to connect to the internet.

用于 VM 的 Azure Monitor 包含一组针对几项关键性能指标 (KPI) 的性能图表,帮助你确定 VM 的性能状况。Azure Monitor for VMs includes a set of performance charts that target several key performance indicators (KPIs) to help you determine how well a VM is performing. 图表显示一段时间内的资源使用情况,以便你能够识别瓶颈和异常情况。The charts show resource use over a period of time so you can identify bottlenecks and anomalies. 还可以切换到列出每台计算机的透视图,根据所选的指标来查看资源使用情况。You can also switch to a perspective listing each machine to view resource use based on the metric selected. 处理性能时需要考虑大量的要素,而用于 VM 的 Azure Monitor 会监视与处理器、内存、网络适配器和磁盘使用情况相关的操作系统关键性能指标。While there are many elements to consider when dealing with performance, Azure Monitor for VMs monitors key operating system performance indicators related to processor, memory, network adapter, and disk use. 性能图表是对运行状况监视功能的补充,有助于揭示指出可能发生系统组件故障的问题。Performance charts complement the health monitoring feature and help expose issues that indicate a possible system component failure. 用于 VM 的 Azure Monitor 还支持容量规划、微调和优化以实现效率。Azure Monitor for VMs also supports capacity planning and tuning and optimization to achieve efficiency.

Azure Monitor VM 性能选项卡

可以通过两种方式使用用于 VM 的 Azure Monitor 查看在 Azure Stack Hub 中运行的 Windows 和 Linux VM 上发现的应用组件。Viewing the discovered app components on Windows and Linux VMs running in Azure Stack Hub can be observed in two ways with Azure Monitor for VMs. 第一种方式是直接从 VM 查看,第二种方式是从 Azure Monitor 跨 VM 组查看。The first is from a VM directly and the second is across groups of VMs from Azure Monitor. 通过借助用于 VM 的 Azure Monitor 映射了解应用组件一文,可以了解这两个角度的不同体验,以及如何使用映射功能。The Using Azure Monitor for VMs Map to understand app components article will help you understand the experience between the two perspectives and how to use the Map feature.

Azure Monitor VM 映射选项卡

如果用于 VM 的 Azure Monitor 未显示任何性能数据,则必须在 LogAnalytics 工作区“高级设置”中启用 Windows 和 Linux 性能数据收集。In case Azure Monitor for VMs is not showing you any performance data, you have to enable the collection of performance data for Windows and Linux in your LogAnalytics Workspace Advanced Settings.

使用资源管理器模板启用更新管理Enable Update Management using a Resource Manager template

如果有大量 Azure Stack Hub VM,则可以使用此 Azure 资源管理器模板更轻松地在 VM 上部署解决方案。If you have a large number of Azure Stack Hub VMs, you can use this Azure Resource Manager template to more easily deploy the solution on VMs. 该模板将 Microsoft Monitoring Agent 扩展部署到现有的 Azure Stack Hub VM,并将其添加到现有的 Azure LogAnalytics 工作区。The template deploys the Microsoft Monitoring Agent extension to an existing Azure Stack Hub VM and adds it to an existing Azure LogAnalytics workspace.

后续步骤Next steps

优化 SQL Server VM 性能Optimize SQL Server VM performance