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

Azure 虚拟机代理概述Azure Virtual Machine Agent overview

Microsoft Azure 虚拟机代理(VM 代理)是受保护的轻型进程,用于管理 VM 与 Azure 结构控制器的交互。The Microsoft Azure Virtual Machine Agent (VM Agent) is a secured, lightweight process that manages VM interaction with the Azure Fabric Controller. VM 代理有一个主要角色,目的是启用和执行 Azure 虚拟机扩展。The VM Agent has a primary role in enabling and executing Azure virtual machine extensions. VM 扩展可用于对虚拟机进行部署后配置,例如安装和配置软件。VM Extensions enabling post deployment configuration of virtual machines, such as installing and configuring software. 虚拟机扩展还可启用恢复功能,例如重置虚拟机的管理密码。Virtual machine extensions also enable recovery features such as resetting the administrative password of a virtual machine. 没有 Azure VM 代理,虚拟机扩展将无法运行。Without the Azure VM Agent, virtual machine extensions cannot be run.

本文档详细介绍如何安装、检测和删除 Azure 虚拟机代理。This document details installation, detection, and removal of the Azure Virtual Machine Agent.

安装 VM 代理Install the VM Agent

Azure VM 代理默认安装在任何通过 Azure 库映像部署的 Windows 虚拟机上。The Azure VM Agent is installed by default on any Windows virtual machine deployed from an Azure Gallery image. 从门户、PowerShell、命令行接口或 Azure 资源管理器模板部署 Azure 库映像时,也会安装 Azure VM 代理。When deploying an Azure gallery image from the Portal, PowerShell, Command Line Interface, or an Azure Resource Manager template, the Azure VM Agent is also be installed.

手动安装Manual installation

可以使用 Windows 安装程序包手动安装 Windows VM 代理。The Windows VM agent can be manually installed using a Windows installer package. 创建将部署在 Azure 中的自定义虚拟机映像时,可能需要手动安装。Manual installation may be necessary when creating a custom virtual machine image that will be deployed in Azure. 若要手动安装 Windows VM 代理,可从以下位置下载 VM 代理安装程序:Windows Azure VM 代理下载To manually install the Windows VM Agent, download the VM Agent installer from this location Windows Azure VM Agent Download.

双击 Windows 安装程序文件即可安装 VM 代理。The VM Agent can be installed by double-clicking the windows installer file. 若要以自动或无人参与方式安装 VM 代理,请运行以下命令。For an automated or unattended installation of the VM agent, run the following command.

msiexec.exe /i WindowsAzureVmAgent.2.7.1198.778.rd_art_stable.160617-1120.fre /quiet

检测 VM 代理Detect the VM Agent

PowerShellPowerShell

可以使用 Azure 资源管理器 PowerShell 模块检索有关 Azure 虚拟机的信息。The Azure Resource Manager PowerShell module can be used to retrieve information about Azure Virtual Machines. 运行 Get-AzureRmVM 会返回大量信息,包括 Azure VM 代理的预配状态。Running Get-AzureRmVM returns quite a bit of information including the provisioning state for the Azure VM Agent.

Get-AzureRmVM

下面仅仅是部分 Get-AzureRmVM 输出。The following is just a subset of the Get-AzureRmVM output. 请注意嵌套在 OSProfile 中的 ProvisionVMAgent 属性,可以使用该属性来确定 VM 代理是否已部署到虚拟机。Notice the ProvisionVMAgent property nested inside OSProfile, this property can be used to determine if the VM agent has been deployed to the virtual machine.

OSProfile                  :
  ComputerName             : myVM
  AdminUsername            : muUserName
  WindowsConfiguration     :
    ProvisionVMAgent       : True
    EnableAutomaticUpdates : True

可以使用以下脚本返回一个简明列表,其中包含虚拟机名称以及 VM 代理的状态。The following script can be used to return a concise list of virtual machine names and the state of the VM Agent.

$vms = Get-AzureRmVM

foreach ($vm in $vms) {
    $agent = $vm | Select -ExpandProperty OSProfile | Select -ExpandProperty Windowsconfiguration | Select ProvisionVMAgent
    Write-Host $vm.Name $agent.ProvisionVMAgent
}

手动检测Manual Detection

登录到 Microsoft Azure VM 后,可以使用任务管理器检查正在运行的进程。When logged in to a Windows Azure VM, task manager can be used to examine running processes. 要查看 Azure VM 代理,请打开任务管理器 > 单击详细信息选项卡,并查找名为 WindowsAzureGuestAgent.exe 的进程。To check for the Azure VM Agent, open Task Manager > click the details tab, and look for a process name WindowsAzureGuestAgent.exe. 存在该进程表示 VM 代理已安装。The presence of this process indicates that the VM agent is installed.

升级 VM 代理Upgrade the VM Agent

适用于 Windows 的 Azure VM 代理会自动升级。The Azure VM Agent for Windows is automatically upgraded. 新虚拟机在部署到 Azure 后会获得最新 VM 代理。As new virtual machines are deployed to Azure, they receive the latest VM agent. 应手动更新自定义 VM 映像,使之包括新的 VM 代理。Custom VM images should be manually updated to include the new VM agent.