PowerShell Automation

Checking the Status of Azure VM Agent

For Classic VMs, aka Iaas v1, you'll be using the Azure Powershell Module.

Step 1

Open up the Azure Powershell Module

Step 2

Add your Azure Account or Select an Azure Subscription to work with.

Add-AzureAccount 
or
Select-AzureSubscription

Step 3

Get the Agent Status

# Define the VMName Variable
#Select a VM and insert the Name into the VMName variable below.
$VMName = 'UbuClassicTest'

# Define the VM Variable and gather the VM Properties
$VM = Get-AzureVM | ?{$_.name -eq $VMName}

# Use the VM Properties to get the Guest Agent Status
$VM.guestagentstatus

Results should look similar to these:
ProtocolVersion   : 1.0
TimestampUtc      : 3/4/2016 2:57:25 AM
GuestAgentVersion : 2.7.1198.735
Status            : Ready
Code              :
Message           :
FormattedMessage  : Microsoft.WindowsAzure.Commands.ServiceManagement.Model.GuestAgentFormattedMessage

Step 5

Get the Agent Status Message

$VM.guestagentstatus.formattedmessage

Results should look similar to these
GuestAgent is running and accepting new configurations.

Links:

Azure SLT Labs

Azure VM Agent

The Azure VM Agent is utilized for a number of reasons between Azure Services and Extensions. Sometimes VM Agent needs some attention and a simple restart, reinstall, or an update will do the trick.

  • This blog is powershell focused, so methods that do not include powershell may not be covered.

There are several ways to check the VM Agent Status. Your options will be dependent upon the VM type:

ARM VMs

Login into the Portal > Select the VM Properties > Choose Boot Diagnostic Logs or download the Boot Diagnostic Logs

Classic VMs

The agent can be checked by either logging into the VM or using the azure powershell module

Windows & Linux

  • Azure Powershell Module Commands

This gets a specific vm and returns the guest agent status and the last alert message.

$VMName = 'UbuClassicTest'
$VM = Get-AzureVM | ?{$_.name -eq $vmname}
$VM.guestagentstatus
$VM.guestagentstatus.formattedmessage

Windows Logs

There should be a windows event log dedicated to the agent events.

Linux Logs

Logging may be dependent on the linux flavor. Ubuntu logs can be found the following locations.

/var/lib/waagent/*.xml
/var/log/waagent.log
/var/log/azure/*

Support Links
Azure VM Agent and Extensions