Skip to main content

Command Palette

Search for a command to run...

Automatic Windows VM Image update for Azure Local (HCI)

Updated
1 min read
Automatic Windows VM Image update for Azure Local (HCI)

If you are using Azure Local (HCI), you might find the following PowerShell script AzureLocalVMImageUpdater.ps1 useful.

What is it good for?

The code replaces the Windows VM images in the specified Azure Local cluster(s) with the latest compatible version available in the Marketplace. So whenever you create a new VM, you will use the updated OS version.


Requirements

Image name

  • Image must have a suffix -<number> (i.e. Windows2025-01), so if the image gets replaced with the new one, the <number> can be increased to emphasize the change

Permissions

  • IAM (RBAC) assignments for the subscription where the HCI cluster is located

    • Azure Stack HCI Administrator - to be able to manage Azure Local VM Images

    • Reader - to be able to query cluster health, VM Images, and other required resources

PowerShell

  • Core (to be able to use parallel processing)

PowerShell modules

  • Az (Az.Accounts, Az.ResourceGraph)

  • Azure Cli

  • AzureLocalStuff


How to use it?

  • Create Azure Automation Runbook

  • Add required PowerShell modules

  • Grant required IAM role assignments to the Automation Account Managed Identity

  • Customize the $azureLocalClusterList variable to match your environment in the AzureLocalVMImageUpdater.ps1 script

  • Use modified code in your Runbook

  • Set the Runbook schedule and watch the magic :)