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

教程:监视和更新 Azure 中的 Linux 虚拟机Tutorial: Monitor and update a Linux virtual machine in Azure

为确保 Azure 中的虚拟机 (VM) 正常运行,可以查看启动诊断、性能指标,并管理程序包更新。To ensure your virtual machines (VMs) in Azure are running correctly, you can review boot diagnostics, performance metrics and manage package updates. 本教程介绍如何执行下列操作:In this tutorial, you learn how to:

  • 在 VM 上启用启动诊断Enable boot diagnostics on the VM
  • 查看启动诊断View boot diagnostics
  • 查看主机指标View host metrics
  • 在 VM 上启用诊断扩展Enable diagnostics extension on the VM
  • 查看 VM 指标View VM metrics
  • 基于诊断指标创建警报Create alerts based on diagnostic metrics
  • 管理程序包更新Manage package updates
  • 监视器更改和清单Monitor changes and inventory
  • 设置高级监视Set up advanced monitoring

打开 Azure Cloud ShellOpen Azure Cloud Shell

Azure Cloud Shell 是免费的交互式 shell,可以使用它运行本文中的步骤。Azure Cloud Shell is a free, interactive shell that you can use to run the steps in this article. Cloud Shell 中预安装并配置了常用 Azure 工具供你与帐户一起使用。Common Azure tools are preinstalled and configured in Cloud Shell for you to use with your account. 只需选择“复制”按钮即可复制代码,将其粘贴到 Cloud Shell 中,然后按 Enter 来运行它。Just select the Copy button to copy the code, paste it in Cloud Shell, and then press Enter to run it. 可以通过多种方式打开 Cloud Shell,你可以选择其中任一种方式打开 Cloud Shell:There are a few ways to open Cloud Shell, you can choose any one of them to open Cloud Shell:

选择代码块右上角的“试用”。Select Try It in the upper-right corner of a code block. 本文中的 Cloud Shell
在浏览器中打开 Cloud Shell。Open Cloud Shell in your browser. https://shell.azure.com/bash
选择 Azure 门户右上角菜单上的“Cloud Shell”按钮。Select the Cloud Shell button on the menu in the upper-right corner of the Azure portal. 门户中的 Cloud Shell

如果选择在本地安装并使用 CLI,本教程要求运行 Azure CLI 2.0.30 或更高版本。If you choose to install and use the CLI locally, this tutorial requires that you are running the Azure CLI version 2.0.30 or later. 运行 az --version 即可查找版本。Run az --version to find the version. 如果需要进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install Azure CLI.

创建 VMCreate VM

若要查看诊断和指标的状态,需要创建一个 VM。To see diagnostics and metrics in action, you need a VM. 首先,使用 az group create 创建资源组。First, create a resource group with az group create. 以下示例在 eastus 位置创建名为 myResourceGroupMonitor 的资源组。The following example creates a resource group named myResourceGroupMonitor in the eastus location.

az group create --name myResourceGroupMonitor --location eastus

现使用 az vm create 创建 VM。Now create a VM with az vm create. 以下示例将创建名为 myVM 的 VM,并生成 SSH 密钥(如果它们尚不存在于 ~/.ssh/ 中):The following example creates a VM named myVM and generates SSH keys if they do not already exist in ~/.ssh/:

az vm create \
  --resource-group myResourceGroupMonitor \
  --name myVM \
  --image UbuntuLTS \
  --admin-username azureuser \
  --generate-ssh-keys

启用启动诊断Enable boot diagnostics

Linux VM 启动时,启动诊断扩展将捕获启动输出并将其存储在 Azure 存储中。As Linux VMs boot, the boot diagnostic extension captures boot output and stores it in Azure storage. 此数据可以用于排查 VM 启动问题。This data can be used to troubleshoot VM boot issues. 使用 Azure CLI 创建 Linux VM 时,不会自动启用启动诊断。Boot diagnostics are not automatically enabled when you create a Linux VM using the Azure CLI.

在启用启动诊断之前,需要创建一个存储帐户来存储启动日志。Before enabling boot diagnostics, a storage account needs to be created for storing boot logs. 存储帐户的名称必须全局唯一,介于 3 和 24 个字符之间,并且只能包含数字和小写字母。Storage accounts must have a globally unique name, be between 3 and 24 characters, and must contain only numbers and lowercase letters. 使用 az storage account create 命令创建存储帐户。Create a storage account with the az storage account create command. 本示例使用一个随机字符串来创建唯一的存储帐户名称。In this example, a random string is used to create a unique storage account name.

storageacct=mydiagdata$RANDOM

az storage account create \
  --resource-group myResourceGroupMonitor \
  --name $storageacct \
  --sku Standard_LRS \
  --location eastus

启用引导诊断时,需要 Blob 存储容器的 URI。When enabling boot diagnostics, the URI to the blob storage container is needed. 以下命令查询存储帐户以返回此 URI。The following command queries the storage account to return this URI. URI 值存储在名为 bloburi 的变量中,会在下一步骤中使用。The URI value is stored in a variable names bloburi, which is used in the next step.

bloburi=$(az storage account show --resource-group myResourceGroupMonitor --name $storageacct --query 'primaryEndpoints.blob' -o tsv)

现在,请使用 az vm boot-diagnostics enable 启用启动诊断。Now enable boot diagnostics with az vm boot-diagnostics enable. --storage 值是在上一步骤中收集的 Blob URI。The --storage value is the blob URI collected in the previous step.

az vm boot-diagnostics enable \
  --resource-group myResourceGroupMonitor \
  --name myVM \
  --storage $bloburi

查看启动诊断View boot diagnostics

启用引导诊断后,每当停止再启动 VM 时,会将有关启动过程的信息写入日志文件。When boot diagnostics are enabled, each time you stop and start the VM, information about the boot process is written to a log file. 本示例首先使用 az vm deallocate 命令解除分配 VM,如下所示:For this example, first deallocate the VM with the az vm deallocate command as follows:

az vm deallocate --resource-group myResourceGroupMonitor --name myVM

现在,请使用 az vm start 命令启动 VM,如下所示:Now start the VM with the az vm start command as follows:

az vm start --resource-group myResourceGroupMonitor --name myVM

可以使用 az vm boot-diagnostics get-boot-log 命令获取 myVM 的启动诊断数据,如下所示:You can get the boot diagnostic data for myVM with the az vm boot-diagnostics get-boot-log command as follows:

az vm boot-diagnostics get-boot-log --resource-group myResourceGroupMonitor --name myVM

查看主机指标View host metrics

Linux VM 在 Azure 中有一个与它交互的专用主机。A Linux VM has a dedicated host in Azure that it interacts with. 系统会自动收集该主机的指标,可以在 Azure 门户中查看这些指标,如下所示:Metrics are automatically collected for the host and can be viewed in the Azure portal as follows:

  1. 在 Azure 门户中选择“资源组”,选择“myResourceGroupMonitor”,并在资源列表中选择“myVM”。In the Azure portal, select Resource Groups, choose myResourceGroupMonitor, and then select myVM in the resource list.
  2. 若要查看主机 VM 的性能情况,请在 VM 窗口中选择“指标”,并选择“可用指标”下面的任一“[主机]”指标。To see how the host VM is performing, select Metrics on the VM window, then choose any of the [Host] metrics under Available metrics.

    查看主机指标

安装诊断扩展Install diagnostics extension

可以使用基本的主机指标,但若要查看更详细的指标和 VM 特定的指标,需在 VM 上安装 Azure 诊断扩展。The basic host metrics are available, but to see more granular and VM-specific metrics, you need to install the Azure diagnostics extension on the VM. 使用 Azure 诊断扩展可从 VM 检索其他监视数据和诊断数据。The Azure diagnostics extension allows additional monitoring and diagnostics data to be retrieved from the VM. 可以查看这些性能指标,并根据 VM 的性能情况创建警报。You can view these performance metrics and create alerts based on how the VM performs. 诊断扩展是通过 Azure 门户安装的,如下所述:The diagnostic extension is installed through the Azure portal as follows:

  1. 在 Azure 门户中选择“资源组”,选择“myResourceGroupMonitor”,并在资源列表中选择“myVM”。In the Azure portal, choose Resource Groups, select myResourceGroupMonitor, and then select myVM in the resource list.
  2. 选择“诊断设置”。Select Diagnosis settings. 在“选取存储帐户”下拉菜单中,如果尚未选择,请选择在上一部分中创建的“mydiagdata[1234]”帐户。In the Pick a storage account drop-down menu, if not already selected, choose the mydiagdata[1234] account created in the previous section.
  3. 选择“启用来宾级监视”按钮。Select the Enable guest-level monitoring button.

    查看诊断指标

查看 VM 指标View VM metrics

可以像查看主机 VM 指标一样查看 VM 指标:You can view the VM metrics in the same way that you viewed the host VM metrics:

  1. 在 Azure 门户中选择“资源组”,选择“myResourceGroupMonitor”,并在资源列表中选择“myVM”。In the Azure portal, choose Resource Groups, select myResourceGroupMonitor, and then select myVM in the resource list.
  2. 若要查看 VM 的性能情况,请在 VM 窗口上选择“指标”,并选择“可用指标”下的任一“[来宾]”诊断指标。To see how the VM is performing, select Metrics on the VM window, and then select any of the [Guest] diagnostics metrics under Available metrics.

    查看 VM 指标

创建警报Create alerts

可以根据特定的性能指标创建警报。You can create alerts based on specific performance metrics. 例如,当平均 CPU 使用率超过特定的阈值或者可用磁盘空间低于特定的空间量时,警报可以发出通知。Alerts can be used to notify you when average CPU usage exceeds a certain threshold or available free disk space drops below a certain amount, for example. 警报显示在 Azure 门户中,也可以通过电子邮件发送。Alerts are displayed in the Azure portal or can be sent via email. 还可以触发 Azure 自动化 Runbook 或 Azure 逻辑应用来响应生成的警报。You can also trigger Azure Automation runbooks or Azure Logic Apps in response to alerts being generated.

以下示例针对平均 CPU 使用率创建警报。The following example creates an alert for average CPU usage.

  1. 在 Azure 门户中选择“资源组”,选择“myResourceGroupMonitor”,并在资源列表中选择“myVM”。In the Azure portal, select Resource Groups, select myResourceGroupMonitor, and then select myVM in the resource list.
  2. 选择“警报(经典)”,然后在警报窗口顶部选择“添加指标警报(经典)”。Select Alerts (classic), then choose to Add metric alert (classic) across the top of the alerts window.
  3. 为警报提供名称,例如 myAlertRuleProvide a Name for your alert, such as myAlertRule
  4. 若要在 CPU 百分比持续 5 分钟超过 1.0 时触发警报,请保留选中其他所有默认值。To trigger an alert when CPU percentage exceeds 1.0 for five minutes, leave all the other defaults selected.
  5. (可选)选中“电子邮件所有者、参与者和阅读者”对应的框,以便向他们发送电子邮件通知。Optionally, check the box for Email owners, contributors, and readers to send email notification. 默认操作是在门户中显示通知。The default action is to present a notification in the portal.
  6. 选择“确定”按钮。Select the OK button.

管理程序包更新Manage package updates

使用更新管理可以管理 Azure Linux VM 的更新和修补程序。Update management allows you to manage updates and patches for your Azure Linux VMs. 可以直接在 VM 中快速评估可用更新的状态、计划所需更新的安装以及查看部署结果,验证更新是否已成功应用到 VM。Directly from your VM, you can quickly assess the status of available updates, schedule installation of required updates, and review deployment results to verify updates were applied successfully to the VM.

有关定价信息,请参阅更新管理的自动化定价For pricing information, see Automation pricing for Update management

启用更新管理Enable Update management

为 VM 启用更新管理:Enable Update management for your VM:

  1. 在屏幕的左侧,选择“虚拟机”。On the left-hand side of the screen, select Virtual machines.
  2. 从列表中选择一个虚拟机。From the list, select a VM.
  3. 在 VM 屏幕上的“操作”部分中,选择“更新管理”。On the VM screen, in the Operations section, select Update management. “启用更新管理”屏幕随即打开。The Enable Update Management screen opens.

执行验证以确定是否为该 VM 启用了更新管理。Validation is performed to determine if Update management is enabled for this VM. 验证包括检查 Log Analytics 工作区和链接的自动化帐户,以及解决方案是否在工作区中。The validation includes checks for a Log Analytics workspace and linked Automation account, and if the solution is in the workspace.

Log Analytics 工作区用于收集由功能和服务(如更新管理)生成的数据。A Log Analytics workspace is used to collect data that is generated by features and services such as Update management. 工作区提供了一个位置来查看和分析来自多个数据源的数据。The workspace provides a single location to review and analyze data from multiple sources. 若要在需要更新的 VM 上执行其他操作,可使用 Azure 自动化运行针对 VM 的 Runbook,例如下载和应用更新。To perform additional actions on VMs that require updates, Azure Automation allows you to run runbooks against VMs, such as download and apply updates.

验证过程还会检查 VM 是否预配了 Microsoft Monitoring Agent (MMA) 和自动化混合 Runbook 辅助角色。The validation process also checks to see if the VM is provisioned with the Microsoft Monitoring Agent (MMA) and Automation hybrid runbook worker. 此代理用于与虚拟机通信并获取关于更新状态的信息。This agent is used to communicate with the VM and obtain information about the update status.

选择 Log Analytics 工作区和自动化帐户,然后选择“启用”以启用此解决方案。Choose the Log analytics workspace and automation account and select Enable to enable the solution. 启用此解决方案最长需要 15 分钟的时间。The solution takes up to 15 minutes to enable.

如果在载入过程中发现缺少下列任何先决条件,则会自动添加这些条件:If any of the following prerequisites were found to be missing during onboarding, they're automatically added:

“更新管理”屏幕随即打开。The Update Management screen opens. 配置要使用的位置、Log Analytics 工作区和自动化帐户,然后选择“启用”。Configure the location, Log analytics workspace and Automation account to use and select Enable. 如果这些字段灰显,则意味着已为 VM 启用其他自动化解决方案,因此必须使用同一工作区和自动化帐户。If the fields are grayed out, that means another automation solution is enabled for the VM and the same workspace and Automation account must be used.

启用“更新管理解决方案”

启用解决方案最多可能需要 15 分钟。Enabling the solution can take up to 15 minutes. 在此期间,不应关闭浏览器窗口。During this time, you shouldn't close the browser window. 启用该解决方案后,VM 中缺少的更新信息会流向 Log Analytics。After the solution is enabled, information about missing updates on the VM flows to Log Analytics. 这些数据需花费 30 分钟到 6 小时的时间才能用于分析。It can take between 30 minutes and 6 hours for the data to be available for analysis.

查看更新评估View update assessment

启用“更新管理”后,“更新管理”屏幕随即显示。After Update management is enabled, the Update management screen appears. 评估更新完成后,可在“缺失更新”选项卡上查看缺失更新的列表。After the evaluation of updates is complete, you see a list of missing updates on the Missing updates tab.

查看更新状态

计划更新部署Schedule an update deployment

若要安装更新,请计划一个遵循你的发布时间和服务窗口的部署。To install updates, schedule a deployment that follows your release schedule and service window. 可选择在部署中包括哪种更新类型。You can choose which update types to include in the deployment. 例如,可包括关键或安全更新,排除更新汇总。For example, you can include critical or security updates and exclude update rollups.

若要为 VM 计划新的更新部署,请选择“更新管理”屏幕顶部的“计划更新部署”。To schedule a new Update Deployment for the VM, select Schedule update deployment at the top of the Update management screen. 在“新建更新部署”屏幕中,指定以下信息:In the New update deployment screen, specify the following information:

  • 名称- 提供用于标识更新部署的唯一名称。Name - Provide a unique name to identify the update deployment.
  • 更新分类- 选择部署中包含的更新部署的软件类型。Update classification - Select the types of software the update deployment included in the deployment. 分类类型:The classification types are:
    • 关键和安全更新Critical and security updates
    • 其他更新Other updates
  • 要排查的更新 - 可以提供一个列表,其中包含在更新部署过程中应跳过的包名。Updates to Exclude - You can provide a list of package names that should be skipped during the update deployment. 包名支持通配符(例如,*kernal*)。Package names support wildcards (such as, *kernal*).

    更新计划设置屏幕

  • 计划设置- 可以接受默认的日期和时间,即当前时间后 30 分钟,或指定不同的时间。Schedule settings - You can either accept the default date and time, which is 30 minutes after current time, or specify a different time. 还可以指定部署是发生一次还是设置定期计划。You can also specify whether the deployment occurs once or set up a recurring schedule. 若要设置定期计划,请选择“重复周期”下的“重复执行”选项。Select the Recurring option under Recurrence to set up a recurring schedule.

    更新计划设置屏幕

  • 维护时段(分钟) - 指定要在其中进行更新部署的时间段。Maintenance window (minutes) - Specify the period of time you want the update deployment to occur within. 这有助于确保在定义的服务时段内执行更改。This helps ensure changes are performed within your defined service windows.

完成配置计划后,选择“创建”按钮,然后返回到状态仪表板。After you have completed configuring the schedule, select Create button and you return to the status dashboard. 请注意,“已计划”表显示你创建的部署计划。Notice that the Scheduled table shows the deployment schedule you created.

警告

对于需要重新启动的更新,VM 将自动重启。For updates that require a reboot, the VM is restarted automatically.

查看更新部署结果View results of an update deployment

在计划性部署开始后,可以在“更新管理”屏幕的“更新部署”选项卡上查看该部署的状态。After the scheduled deployment starts, you can see the status for that deployment on the Update deployments tab on the Update management screen. 如果部署当前正在运行,则状态显示为“正在运行”。If it is currently running, it's status shows as In progress. 如果部署已成功完成,则状态会更改为“成功”。After it completes, if successful, it changes to Succeeded. 如果部署中有一个或多个更新失败,则状态为“部分失败”。If there is a failure with one or more updates in the deployment, the status is Partially failed. 选择已完成的更新部署,查看该更新部署的仪表板。Select the completed update deployment to see the dashboard for that update deployment.

特定部署的更新部署状态仪表板

在“更新结果”中,磁贴总结了 VM 上更新和部署结果的总数。In Update results tile is a summary of the total number of updates and deployment results on the VM. 右侧的表格详细列出了每个更新的细目以及安装结果,结果可能是以下值之一:In the table to the right is a detailed breakdown of each update and the installation results, which could be one of the following values:

  • 未尝试 - 由于定义的维护时段时长不足,因而未安装更新。Not attempted - the update was not installed because there was insufficient time available based on the maintenance window duration defined.
  • 成功- 更新成功Succeeded - the update succeeded
  • 失败- 更新失败Failed - the update failed

若要查看部署创建的所有日志条目,请选择“所有日志”。Select All logs to see all log entries that the deployment created.

选择“输出”磁贴,查看负责管理目标 VM 更新部署的 runbook 的作业流。Select the Output tile to see job stream of the runbook responsible for managing the update deployment on the target VM.

若要查看有关部署中错误的详细信息,请选择“错误”。Select Errors to see detailed information about any errors from the deployment.

监视器更改和清单Monitor changes and inventory

可以收集和查看清单,了解计算机上的软件、文件、Linux 守护程序、Windows 服务和 Windows 注册表项。You can collect and view inventory for software, files, Linux daemons, Windows Services, and Windows Registry keys on your computers. 跟踪计算机的配置有助于查明环境中的操作问题,更好地了解计算机的状态。Tracking the configurations of your machines can help you pinpoint operational issues across your environment and better understand the state of your machines.

启用更改和清单管理Enable Change and Inventory management

为 VM 启用更改和清单管理:Enable Change and Inventory management for your VM:

  1. 在屏幕的左侧,选择“虚拟机”。On the left-hand side of the screen, select Virtual machines.
  2. 从列表中选择一个虚拟机。From the list, select a VM.
  3. 在 VM 屏幕上的“操作”部分中,选择“清单”或“更改跟踪”。On the VM screen, in the Operations section, select Inventory or Change tracking. 此时会打开“启用更改跟踪和清单”屏幕。The Enable Change Tracking and Inventory screen opens.

配置要使用的位置、Log Analytics 工作区和自动化帐户,然后选择“启用”。Configure the location, Log analytics workspace and Automation account to use and select Enable. 如果这些字段灰显,则意味着已为 VM 启用其他自动化解决方案,因此必须使用同一工作区和自动化帐户。If the fields are grayed out, that means another automation solution is enabled for the VM and the same workspace and Automation account must be used. 即使这些解决方案在菜单上是分开的,它们也是同一解决方案。Even though the solutions are separate on the menu, they are the same solution. 启用一个解决方案就会为 VM 启用两个解决方案。Enabling one enables both for your VM.

启用更改和清单跟踪

启用解决方案后,可能需要一些时间在 VM 上收集清单,然后才显示数据。After the solution has been enabled, it may take some time while inventory is being collected on the VM before data appears.

跟踪更改Track changes

在 VM 中的“操作”下选择“更改跟踪”。On your VM, select Change Tracking under OPERATIONS. 选择“编辑设置”,此时会显示“更改跟踪”页。Select Edit Settings, the Change Tracking page is displayed. 选择要跟踪的设置类型,然后选择“+ 添加”以配置设置。Select the type of setting you want to track and then select + Add to configure the settings. Linux 上的可用选项为“Linux 文件”。The available option Linux is Linux Files

有关更改跟踪的详细信息,请参阅排查 VM 上的更改问题For detailed information on Change Tracking see, Troubleshoot changes on a VM

查看清单View inventory

在 VM 中的“操作”下选择“清单”。On your VM, select Inventory under OPERATIONS. 在“软件”选项卡上有一个表,列出了已发现的软件。On the Software tab, there is a table list the software that had been found. 可在表中查看每个软件记录的高级详细信息。The high-level details for each software record are viewable in the table. 这些详细信息包括软件名称、版本、发布者和上次刷新时间。These details include the software name, version, publisher, last refreshed time.

查看清单

监视活动日志和更改Monitor Activity logs and changes

在 VM 的“更改跟踪”页中,选择“管理活动日志连接”。From the Change tracking page on your VM, select Manage Activity Log Connection. 此任务打开“Azure 活动日志”页。This task opens the Azure Activity log page. 选择“连接”,将更改跟踪连接到 VM 的 Azure 活动日志。Select Connect to connect Change tracking to the Azure activity log for your VM.

启用此设置后,导航到 VM 的“概览”页,然后选择“停止”以停止 VM。With this setting enabled, navigate to the Overview page for your VM and select Stop to stop your VM. 出现提示时,选择“是”即可停止 VM。When prompted, select Yes to stop the VM. 将 VM 解除分配以后,请选择“启动”以重启 VM。When it is deallocated, select Start to restart your VM.

停止和启动 VM 时,会在活动日志中记录一个事件。Stopping and starting a VM logs an event in its activity log. 导航回到“更改跟踪”页。Navigate back to the Change tracking page. 选择页面底部的“事件”选项卡。Select the Events tab at the bottom of the page. 一段时间后,事件会显示在图表和表中。After a while, the events shown in the chart and the table. 可以选择每个事件来查看其详细信息。Each event can be selected to view detailed information on the event.

在活动日志中查看更改

此图表显示了一段时间内发生的更改。The chart shows changes that have occurred over time. 添加活动日志连接以后,顶部的线形图会显示 Azure 活动日志事件。After you have added an Activity Log connection, the line graph at the top displays Azure Activity Log events. 条形图的每一行代表不同类型的可跟踪更改。Each row of bar graphs represents a different trackable Change type. 这些类型是 Linux 守护程序、文件、软件。These types are Linux daemons, files, and software. “更改”选项卡显示在可视化效果中显示的更改的详细信息,按更改发生时间以降序方式排列(最近发生的排在最前面)。The change tab shows the details for the changes shown in the visualization in descending order of time that the change occurred (most recent first).

高级监视Advanced monitoring

可以使用 Azure 自动化提供的“更新管理”及“更改和清单”等解决方案对 VM 进行更高级的监视。You can do more advanced monitoring of your VM by using the solutions like Update Management and Change and Inventory provided by Azure Automation.

可以访问 Log Analytics 工作区时,可以通过选择“设置”下的“高级设置”来找到工作区密钥和工作区标识符。When you have access to the Log Analytics workspace, you can find the workspace key and workspace identifier on by selecting Advanced settings under SETTINGS. 请将 <workspace-key> 和 <workspace-id> 替换为 Log Analytics 工作区中的值,然后即可使用 az vm extension set 将扩展添加到 VM:Replace <workspace-key> and <workspace-id> with the values for from your Log Analytics workspace and then you can use az vm extension set to add the extension to the VM:

az vm extension set \
  --resource-group myResourceGroupMonitor \
  --vm-name myVM \
  --name OmsAgentForLinux \
  --publisher Microsoft.EnterpriseCloud.Monitoring \
  --version 1.3 \
  --protected-settings '{"workspaceKey": "<workspace-key>"}' \
  --settings '{"workspaceId": "<workspace-id>"}'

几分钟后,应该会在 Log Analytics 工作区中看到新 VM。After a few minutes, you should see the new VM in the Log Analytics workspace.

OMS 边栏选项卡

后续步骤Next steps

在本教程中,将配置、审核和管理虚拟机更新。In this tutorial, you configured, reviewed, and managed updates for a VM. 你已了解如何:You learned how to:

  • 在 VM 上启用启动诊断Enable boot diagnostics on the VM
  • 查看启动诊断View boot diagnostics
  • 查看主机指标View host metrics
  • 在 VM 上启用诊断扩展Enable diagnostics extension on the VM
  • 查看 VM 指标View VM metrics
  • 基于诊断指标创建警报Create alerts based on diagnostic metrics
  • 管理程序包更新Manage package updates
  • 监视器更改和清单Monitor changes and inventory
  • 设置高级监视Set up advanced monitoring

请转到下一教程来了解 Azure 安全中心。Advance to the next tutorial to learn about Azure Security Center.