VM Agent and Extensions – Part 2

4月 15, 2014 に投稿済み

Senior Program Manager, Microsoft Azure
The previous blog ‘VM Agent & Extensions – Part 1’  hopefully gave an overview of VM Agent, its benefits and information on how to create new VMs with VM Agent enabled. In part 2 of this blog series, we’ll discuss two key scenarios – enabling VM Agent on existing VMs and from VMs created from disks.

Enabling VM Agent on Existing VMs:

If you have an Azure VM that was created before the VM Agent was available, this workflow will describe how to enable the VM Agent on such a VM and thereby enabling Extensions on the VM.

Verify VM Agent is not already enabled on the VM:

This can be done using the following  Azure PowerShell  cmdlets: $x = Get-AzureVM -ServiceName $serviceName Verify ‘$x.VM.ProvisionGuestAgent’ is false. If $x.VM.ProvisionGuestAgent is true, then the VM already has VM Agent. The rest of the steps can be skipped.

Prep the VM by Installing Microsoft Azure VM Agent:

Azure VM Agent installer is a standalone MSI for installing VM Agent binaries on the VM. Installing the VM Agent involves one easy step of downloading the MSI and launching it. Follow the installer workflow as shown below to install VM Agent. Note : On domain joined VMs, VM Agent msi can sometimes hang, to workaround this, launch the msi from an elevated prompt.

Set a flag from PowerShell to indicate that VM Agent has been installed:

Note : On domain joined VMs, VM Agent msi can sometimes hang, to workaround this, launch the msi from an elevated prompt. Now that the VM Agent has been installed on the VM, the next step is inform the Azure platform that the VM now has the VM Agent installed. That can be done by running the following Azure PowerShell cmdlets: $vm = Get-AzureVM –serviceName $svc –Name $name $vm.VM.ProvisionGuestAgent = $TRUE Update-AzureVM –Name $name -VM $vm.VM -ServiceName $svc NOTE: Azure PowerShell cmdlets can be downloaded from here. The VM is now ready to run any VM Extensions! Note: On Linux VMs, Azure Linux Agent is responsible for configuring VM Extensions. Details on installing Linux Agent can be found in the blog post here.

How to enable VM Agent and Extensions on VMs created from Disks:

Another common scenario for creating VMs is to create Azure VMs from a Disk. If you are using a Sysprep’ed image from the Azure Portal, the VM Agent gets enabled in the create VM workflow without any extra steps. But if you are using a specialized disk, then the VM Agent needs to be manually installed. The steps below describes the process involved.

Install VM Agent on the VHD:

Create a VM On-Premises using the disk and install VM Agent using the MSI. Upload the VHD to Azure.

Create a VM from the disk

From the Portal, create a VM from the gallery and select the uploaded VHD. In the VM creation workflow, select the flag to indicate that the disk already contains the VM Agent. After this point extensions can be added to the VM during or after VM creation.

3.    What’s next after enabling VM Agent?

Once the VM Agent is enabled on the VM, any available extension like BGInfo or VMAccess can be added to the VM. In the next few blogs we’ll discuss how to discover additional extensions and add them to the VM, like running arbitrary custom scripts directly on a running VM.

4.    Feedback/Questions?

Please post your comments/questions about VM Agent or Extensions to here. We’d love to hear from you!