Azure – You can now automatically upgrade the extension of your virtual machine (preview)

As you know you can add extensions (small applications that provide post-deployment configuration and automation tasks) to your virtual machine running on Azure.

Well, you can now get these extensions automatically upgrade when there is a new version.

This is  a preview capability which means there is no SLA associated with it in case of trouble.

Automatic Extension Upgrade has the following features:

  • Supported for Azure VMs and Azure Virtual Machine Scale Sets. Service Fabric Virtual Machine Scale Sets are currently not supported
  • Upgrades are applied in an availability-first deployment model
  • When applied to a Virtual Machine Scale Sets, no more than 20% of the Virtual Machine Scale Sets virtual machines will be upgraded in a single batch (subject to a minimum of one virtual machine per batch)
  • Works for all VM sizes, and for both Windows and Linux extensions
  • Automatic extension upgrade can be enabled on a Virtual Machine Scale Sets of any size
  • Each supported extension is enrolled individually, and you can choose which extensions to upgrade automatically
  • Supported in all public cloud regions

If, within 5 minutes after the extension has been upgraded, the virtual machine is seen unhealthy then the extension is automatically rolled back to the previous version.

Currently only 2 extensions support the automatic upgrade:

  • Microsoft Dependency Agent
  • Application Health

If you want to evaluate the capability, you need to run the below PowerShell commands (or Azure Cli equivalent)

  • Register the required provider

Register-AzProviderFeature -FeatureName AutomaticExtensionUpgradePreview -ProviderNamespace Microsoft.Compute

  • After the registration is completed propagate the change

Register-AzResourceProvider -ProviderNamespace Microsoft.Compute

Then you can enable the supported extensions using the Set-AzVMExtension for virtual machine or Add-AzVmssExtension for virtual machine scale set

Set-AzVMExtension -ExtensionName “Microsoft.Azure.Monitoring.DependencyAgent” -ResourceGroupName “resource group of the VM” -VMName “VM name” -Publisher “Microsoft.Azure.Monitoring.DependencyAgent” -ExtensionType “DependencyAgentWindows” -TypeHandlerVersion 9.5 –Location <location of the VM> -EnableAutomaticUpgrade $true

Add-AzVmssExtension –VirtualMachineScaleSet <VM scale set> -Name “Microsoft.Azure.Monitoring.DependencyAgent” -Publisher “Microsoft.Azure.Monitoring.DependencyAgent” -Type “DependencyAgentWindows” -TypeHandlerVersion 9.5 -EnableAutomaticUpgrade $true