适用于 Windows VM 的 Azure 诊断扩展Azure Diagnostics Extension for Windows VMs

概述Overview

Azure 诊断 VM 扩展可用来从 Windows VM 收集监视数据,例如性能计数器和事件日志。The Azure Diagnostics VM extension enables you to collect monitoring data, such as performance counters and event logs, from your Windows VM. 你可以精细地指定要收集什么数据以及希望该数据出现在何处,例如 Azure 存储帐户或 Azure 事件中心。You can granularly specify what data you want to collect and where you want the data to go, such as an Azure Storage account or an Azure Event Hub. 还可以使用该数据在 Azure 门户中构建图表或创建指标警报。You can also use this data to build charts in the Azure portal or create metric alerts.

先决条件Prerequisites

操作系统Operating system

Azure 诊断扩展可以针对 Windows 10 客户端,Windows Server 2008 R2、2012、2012 R2 和 2016 运行。The Azure Diagnostics Extension can be run against Windows 10 Client, Windows Server 2008 R2, 2012, 2012 R2, and 2016.

Internet 连接Internet connectivity

Azure 诊断扩展要求目标虚拟机已连接到 Internet。The Azure Diagnostics Extension requires that the target virtual machine is connected to the internet.

扩展架构Extension schema

本文档介绍了 Azure 诊断扩展架构和属性值。The Azure Diagnostics Extension schema and property values are described in this document.

模板部署Template deployment

可使用 Azure Resource Manager 模板部署 Azure VM 扩展。Azure VM extensions can be deployed with Azure Resource Manager templates. 可在 Azure 资源管理器模板中使用上一部分中详细说明的 JSON 架构,以在 Azure 资源管理器模板部署期间运行 Azure 诊断扩展。The JSON schema detailed in the previous section can be used in an Azure Resource Manager template to run the Azure Diagnostics extension during an Azure Resource Manager template deployment. 请参阅将监视和诊断与 Windows VM 和 Azure 资源管理器模板配合使用See Use monitoring and diagnostics with a Windows VM and Azure Resource Manager templates.

Azure CLI 部署Azure CLI deployment

可以使用 Azure CLI 将 Azure 诊断扩展部署到现有的虚拟机。The Azure CLI can be used to deploy the Azure Diagnostics extension to an existing virtual machine. 请将受保护的设置和设置属性替换为以上扩展架构中的有效 JSON。Replace the protected settings and settings properties with valid JSON from the extension schema above.

az vm extension set \
  --resource-group myResourceGroup \
  --vm-name myVM \
  --name IaaSDiagnostics \
  --publisher Microsoft.Azure.Diagnostics \
  --version 1.9.0.0 --protected-settings protected-settings.json \
  --settings public-settings.json 

PowerShell 部署PowerShell deployment

可以使用 Set-AzVMDiagnosticsExtension 命令将 Azure 诊断扩展添加到现有的虚拟机。The Set-AzVMDiagnosticsExtension command can be used to add the Azure Diagnostics extension to an existing virtual machine. 另请参阅使用 PowerShell 在运行 Windows 的虚拟机中启用 Azure 诊断See also Use PowerShell to enable Azure Diagnostics in a virtual machine running Windows.

$vm_resourcegroup = "myvmresourcegroup"
$vm_name = "myvm"
$diagnosticsconfig_path = "DiagnosticsPubConfig.xml"

Set-AzVMDiagnosticsExtension -ResourceGroupName $vm_resourcegroup `
  -VMName $vm_name `
  -DiagnosticsConfigurationPath $diagnosticsconfig_path

故障排除和支持Troubleshoot and support

故障排除Troubleshoot

有关扩展部署状态的数据可以从 Azure 门户和使用 Azure CLI 进行检索。Data about the state of extension deployments can be retrieved from the Azure portal, and by using the Azure CLI. 若要查看给定 VM 的扩展部署状态,请使用 Azure CLI 运行以下命令。To see the deployment state of extensions for a given VM, run the following command using the Azure CLI.

az vm extension list --resource-group myResourceGroup --vm-name myVM -o table

有关 Azure 诊断扩展的更全面的故障排除指南,请参阅此文章See this article for a more comprehensive troubleshooting guide for the Azure Diagnostics extension.

支持Support

如果对本文中的任何观点存在疑问,可以联系 Azure 支持上的 Azure 专家。If you need more help at any point in this article, you can contact the Azure experts on the Azure support. 或者,也可以提出 Azure 支持事件。Alternatively, you can file an Azure support incident. 请转到 Azure 支持站点提交请求。Go to the Azure support site and submit your request. 有关使用 Azure 支持的信息,请阅读 Azure 支持常见问题For information about using Azure Support, read the Azure support FAQ.

后续步骤Next Steps