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.

VSAN from StarWind eliminates any need for physical shared storage just by mirroring internal flash and storage resources between hypervisor servers. Furthermore, the solution can be run on the off-the-shelf hardware. Such design allows VSAN from StarWind to not only achieve high performance and efficient hardware utilization but also reduce operational and capital expenses.

Learn more about ➡ VSAN from StarWind

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!

Views All Time
5
Views Today
18
Appreciate how useful this article was to you?
1 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 5
5 out of 5, based on 1 review
Loading...
Back to blog
The following two tabs change content below.
Nicolas Prigent
Nicolas Prigent
Nicolas Prigent works as a System Engineer, based in Switzerland with a primary focus on Microsoft technologies. Nicolas is Microsoft MVP in Cloud And Datacenter Management with 8 years experience in administering Windows Servers, Hyper-V and System Center products. He also received the "PowerShell Heroes 2016" Award.