Search
StarWind is a hyperconverged (HCI) vendor with focus on Enterprise ROBO, SMB & Edge

Working with Azure VM Extensions

  • March 12, 2019
  • 9 min read
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.

azure vm

Introduction

Deploying a Virtual Machine in Azure can be done using the Azure Portal or using the command-line such as Azure PowerShell and Azure CLI. After deploying a Virtual Machine, you will need to configure the VM to suit your needs. In a perfect world, we need to automate our most important tasks in order to save time.

With Azure VM Extensions, you can configure for example:

  • Monitoring
  • Security
  • Configuration management
  • Backup
  • And more…

Azure Virtual Machine Extensions are small applications that provide post-deployment configuration and will simplify the configuration management of Virtual Machines. This feature uses Windows and Linux Azure agents that are automatically installed during the provisioning process. This agent is named ‘Microsoft Azure Virtual Machine Agent’ and it is the only prerequisite in order to use the Azure VM Extensions.

Listing Azure VM Extensions

As shown below, you can see the list from the Azure Portal by navigating to the Virtual Machine blade:

  • Go to the Azure portal.
  • Locate the Virtual Machine that you want to add Extension.
  • Click Extensions in the Settings area

Azure portal

You can also use Windows PowerShell to list the Azure VM Extensions using the following command. The Get-AzureRmVMExtensionImage cmdlet will list the VM Extensions available in the West Europe region:

script

At the time of writing this article, in the West Europe region, there are 879 VM extensions at your disposal.

Using Azure VM Extensions

First, you need to check the VM Agent status using the following command:

The command returns True, which indicates that the VM Agent is installed, and running.

script

Log in to the VM and open the Task Manager to check the WindowsAzureGuestAgent.exe process. It means that the VM Agent is installed:

Task Manager

To finish with the Azure Agent, it is located in the following directory: C:\WindowsAzure

WindowsAzure

Installing Azure VM Extensions

Using the Azure Portal, you can easily add an extension to an existing Virtual Machine. Navigate to an existing Virtual Machine, then select Extensions and click Add.

Extensions

Select the Extension you want to install from the list of extensions. In my case, I selected the Custom Script Extension, which is a tool that can be used to launch and execute customization tasks. With this extension, you can run PowerShell scripts to configure the Virtual Machine.

Custom Script Extension

Provide the configuration parameters as required. Here, you must provide the script file and arguments.

install extention

Click OK to start the installation process.

Custom scripts are great to perform specific tasks. There are just few things to take into consideration, such as:

  • The script can be stored on GitHub, Azure Blob Storage, or anywhere the VM can access the repository.
  • If your script is located on the Internet, then the firewall rules must be opened.
  • If you run a bash script, for example, you must run the script on supported OS’s (e.g. Linux OS)

Now, if you deploy a new Virtual Machine, you will notice the following tab called “Guest config“. The VM Extension can be configured within the deployment wizard.

Guest config - img

Once the VM Extension is installed, you can check the status in the Extensions blade:

Extensions

In my case, I can see two VM Extensions:

  • A Custom PowerShell Script
  • The Site24x7 agent

It is possible to check if there are VM Extensions already installed on a Virtual Machine using the Get-AzureRmVM cmdlet:

script

To install a new VM Extension, there are several PowerShell cmdlets at your disposal that you can list using the following command:

script

Here is an example of custom script implementation with PowerShell:

You can store a custom script in your Azure Blob storage.

Conclusion

Thanks to Azure Virtual Machine Extensions, you can very easily and quickly configure your machines. You can also automate tasks that you performed manually.

If the agent is not installed in the Virtual Machine, you can install it very easily. In this case, you can download the agent and double-click the Windows installer file.

Thanks for reading!

Hey! Found Nicolas’s insights useful? Looking for a cost-effective, high-performance, and easy-to-use hyperconverged platform?
Taras Shved
Taras Shved StarWind HCI Appliance Product Manager
Look no further! StarWind HCI Appliance (HCA) is a plug-and-play solution that combines compute, storage, networking, and virtualization software into a single easy-to-use hyperconverged platform. It's designed to significantly trim your IT costs and save valuable time. Interested in learning more? Book your StarWind HCA demo now to see it in action!