TL;DR You can now directly access the Azure VMs in a VM Scale Set if you select the right option when you create it.

Quick one, again as a result of something a client asked us to do.

We have all these VMs in a scale set but we need to swap them to a new network, in this specific Azure environment, by the way each of them has been individually configured and has data we can’t lose on their C: drive.

Now Virtual Machine Scale Sets were not really set up for this, they provide a way to scale, clue is in the name, a number of identical instances of machines, so its easy to create and destroy them. This is ideal if you have a set of stateless transactions or processes that are too heavy for an Azure Function or need access to something they don’t support, like a lot of on-premises software that needs an actual Windows OS to operate. These ‘uniform’ scale sets are ideal for this.

However the big drawback is because they are ‘all the same’ most of the Azure REST API, and hence all the other Command Line Tools and User Interfaces associated with Virtual Machines won’t work with them. They shouldn’t as they would let you customise each one.

However a while ago Microsoft introduced ‘flexible’ Scale Sets, see Orchestration modes for Virtual Machine Scale Sets in Azure — Azure Virtual Machine Scale Sets | Microsoft Learn, which orchestrate the creation and destruction of Virtual Machines based on images but once created they are accessible to the Azure VM REST API and so can be manipulated like any other virtual machines, including swapping their OS disks.

These are ideal for most Azure VM workloads, as these days Azure Functions are the go to for automating stateless processes, and in fact are now the default for any new Azure VM Scale Sets.

In addition each of the Azure VMs in the scale set can be seen directly in the Azure Resource Group, rather than being hidden in the Scale Set itself.

So in the end it was a case of creating a flexible scale set, creating an identical number of images to the original Virtual Machines, snapshotting the original Virtual Machines Disks and then swapping them into the new Virtual Machines.

If you’d like to see some code for this its here Azure VM Scale Set.

TL;CR You can now directly access the Azure VMs in a VM Scale Set if you select the right option when you create it.

--

--

Sebastian Rogers

Technical Director for Simple Innovations Ltd. First paid for code in 1980, but still has all his own hair.