Table of Contents

Virtual Machine (VM) extensions

VM extensions are small applications that allow you to automate post-deployment configurations and tasks on Azure VMs, which simplify administrative tasks and add functionality to your VMs. They can be used for various tasks like running scripts, installing software, configuring settings, and more.

Deploying these extensions can be primarily done via Azure portal, Azure CLI, Azure PowerShell, and Azure Resource Manager templates. The AZ-104 Microsoft Azure Administrator exam touches on these aspects as a part of its syllabus.

Types of VM Extensions

Azure has multiple extension types based on the task you wish to execute. Some of the widely used extensions are:

  • Custom Script Extension: This extension allows you to write scripts in any language supported by your VM which can be like installing software or setting the system configurations.
  • DSC Extension: The Desired State Configuration (DSC) extension is a powerful tool that allows you to manage and configure your Azure VMs in a declarative way.
  • Diagnostics Extension: This extension helps you to monitor your VM. With this extension, you can collect performance metrics and diagnostic data.

Deploying VM Extensions using Azure Portal

The procedure to deploy a VM extension using Azure portal is as follows:

  1. Navigate to the Azure Portal and go to the Virtual machines blade.
  2. Select the VM on which you want to deploy the extension.
  3. From the left-hand menu, under the settings tab, click on extensions.
  4. Click on the ‘Add’ button on the top of the page which will start the process of adding a new VM extension.
  5. Select the extension you wish to add from the list and click on create.

Deploying VM Extensions using Azure CLI

The Azure CLI is a powerful tool that allows you to interact with Azure resources. For deploying VM extensions using Azure CLI, you can use the az vm extension set command:


az vm extension set \
--resource-group MyResourceGroup \
--vm-name MyVM \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"fileUris":["https://example.com/script.sh"],"commandToExecute":"./script.sh"}'

In the above command, --vm-name is the name of your VM; --name is the name of the extension; --publisher is the publisher of the extension; and --settings specifies the settings for the extension.

Deploying VM Extensions using Azure PowerShell

Azure PowerShell consists of modules that provide cmdlets to manage Azure with Windows PowerShell. Here is an example of how to deploy a custom script extension using Azure PowerShell:


$vm=Get-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM"
Set-AzVMCustomScriptExtension -ResourceGroupName "MyResourceGroup" -Location "East US" -VMName "MyVM" -FileUri "https://example.com/script.ps1" -Run "script.ps1" -VM $vm

Each method of deploying VM extensions has its own advantages and trade-offs. The Azure portal provides an easy to use graphical interface; Azure CLI is a cross-platform tool ideal for scripting and automation; and Azure PowerShell is a powerful scripting environment for Microsoft-stack developers. Choose the one that best fits your use case.

There are a wide variety of VM extensions available and using them effectively can significantly enhance the functionality and manageability of your Azure virtual machines. The AZ-104 Microsoft Azure Administrator exam includes understanding and deploying these Azure VMs extensions which are important for managing and automating tasks on Azure VMs.

Practice Test

True or False: Virtual machine extensions are small applications that provide post-deployment configuration and automation tasks on Azure virtual machines.

  • True
  • False

Answer: True

Explanation: Microsoft Azure provides extensions that can install and configure software on Azure virtual machines after they are deployed.

Which Azure service would you use to extend the functionality and manageability of a VM?

  • a) Azure Logic Apps
  • b) Azure Machine Learning
  • c) Azure VM Extensions
  • d) Azure Kubernetes Service

Answer: c) Azure VM Extensions

Explanation: Azure VM Extensions are small applications that provide post-deployment configuration and automation tasks on Azure virtual machines.

Can a VM extension be removed once it’s installed?

  • a) Yes
  • b) No

Answer: a) Yes

Explanation: While you can change a VM’s configuration any time, the same is true for a VM extension. They can be added and removed at any time during VM’s lifecycle.

True or False: Virtual Machine Extensions can only be used with Linux, not with Windows operating systems.

  • True
  • False

Answer: False

Explanation: Azure VM extensions can be used with both Windows and Linux operating systems.

What are Azure VM extensions primarily used for?

  • a) Managing disaster recovery
  • b) Launching new VMs
  • c) Post-deployment configuration
  • d) Tracking usage costs

Answer: c) Post-deployment configuration

Explanation: Azure VM extensions are used mostly for post-deployment configurations like installing software, monitoring resources, etc.

True or False: The Azure portal is the only way you can deploy Azure virtual machine extensions.

  • True
  • False

Answer: False

Explanation: Azure VM extensions can be deployed using the Azure portal, Azure PowerShell, Azure CLI, or ARM templates.

What limitation does AZ-104 Microsoft Azure Administrator have regarding a VM Extension?

  • a) Size limit of the extension
  • b) The extension cannot be upgraded
  • c) Maximum number of extensions that can be added to a single VM
  • d) There is no limitation

Answer: c) Maximum number of extensions that can be added to a single VM

Explanation: There are limits to the number of extensions that you can add to a VM. For example, for VM size Standard_A1, you can add up to 15 extensions.

True or False: Azure supports third-party VM extensions.

  • True
  • False

Answer: True

Explanation: Azure supports both Microsoft-provided VM extensions as well as third-party VM extensions.

Are all Azure VM Extensions free of cost?

  • a) Yes
  • b) No

Answer: b) No

Explanation: While some extensions are free, others may come with an associated cost.

Will VM extensions work if the VM is in the ‘Stopped’ state?

  • a) Yes
  • b) No

Answer: b) No

Explanation: VM extensions only work when the VM is running.

Which of the following are necessary to deploy an Azure VM extension?

  • a) VM Operating System
  • b) VM size
  • c) Connection to Azure Portal
  • d) All of the above

Answer: d) All of the above

Explanation: To deploy an Azure VM extension, you need an Operating System, a specific VM size to support the extension and a connection to Azure Portal to deploy the extension on VM.

In terms of a VM, can Azure VM Extensions report a status for each of its instances?

  • a) Yes
  • b) No

Answer: a) Yes

Explanation: Yes, Azure VM Extensions can report a status for each of its instances known as the extension instance view.

Which service can be used to monitor Azure VM extensions?

  • a) Azure Storage Account
  • b) Azure Backup
  • c) Azure Monitor
  • d) Azure Logic Apps

Answer: c) Azure Monitor

Explanation: Azure Monitor can be used to monitor the status of Azure VM extensions. It provides base-level infrastructure metrics and logs for most services in Microsoft Azure.

Who can manage Azure VM Extensions?

  • a) Only the original creator of the VM
  • b) Only those with the necessary permissions
  • c) Both a) and b)
  • d) Anyone with access to the machine

Answer: b) Only those with the necessary permissions

Explanation: Only users or roles with the necessary permissions can manage Azure VM Extensions.

True or False: Azure VM Extensions provide features such as the execution of post-deployment scripts, configuration management, and antivirus protections.

  • True
  • False

Answer: True

Explanation: Azure VM extensions provide post-deployment configuration and automation tasks on Azure virtual machines including features such as the execution of post-deployment scripts, configuration management, and antivirus protections.

Interview Questions

What is a VM extension?

A VM extension is a feature of Azure that allows you to programmatically extend a VM’s post-deployment configuration and automation, so the VM can play the desired role in your application.

What is the purpose of Azure VM extensions?

Azure VM extensions are primarily used for post-deployment automation and configuration tasks. They can be used to install software, monitor the VM’s status, and even to automate complex tasks.

How many VM extensions can be added per virtual machine?

An Azure virtual machine can have multiple extensions but bear in mind that certain extensions might be incompatible with each other due to certain constraints.

Which language is used to write Azure VM extensions?

VM extensions can be written in any language that can be executed in the host environment.

How can an Azure VM extension be deployed?

Azure VM extensions can be deployed using Azure portal, CLI, Azure PowerShell, and ARM templates.

Can I remove extensions from a VM?

Yes, Azure VM extensions can be removed if not needed anymore.

Once an extension is removed from a VM, can it be re-added?

Yes, a removed extension can be re-added to a VM as per the requirement.

How can I view the status of a VM extension?

The status of a VM extension can be viewed in the Azure portal, or by using the “Get-AzVMExtension” cmdlet in Azure PowerShell.

What are the types of VM extensions available in Azure?

There are various types of Azure VM extensions available such as custom script extensions, Desired State Configuration (DSC), PowerShell DSC, Docker VM, etc.

How can you secure sensitive data when using VM extensions?

For sensitive data, you should use Azure Key Vault to store and retrieve the data.

Can VM extensions be used with Azure scale sets?

Yes, VM extensions can be added to a scale set definition, and they will be run when a new VM is deployed in the scale set.

What is the Azure Custom Script Extension?

Azure Custom Script Extension is a VM extension that allows you to execute scripts on Azure VM. These scripts can be used to configure the VM as per your application need.

Can VM extensions be used with VMs in an availability set?

Yes, VM extensions can be added to each VM in an availability set.

Can we update an Azure VM extension and if yes, how?

Yes, a VM extension can be updated using Azure portal, CLI, Azure PowerShell, and ARM templates.

Are there any costs associated with Azure VM extensions?

No, Azure does not charge for the VM extensions. You only pay for the compute resources used for the execution of the extension and the associated storage costs.

Leave a Reply

Your email address will not be published. Required fields are marked *