One of the most exciting features to come out of Azure Storage of late is the introduction of Managed Disks. If you are not familiar with the glory of this tool, please see here. In a nutshell, Managed Disks takes away all the pain of managing the underlying Azure Storage Account and lets you, dear user, focus on what's really important - getting things deployed! No more working with iops limits, no more dealing with max number of VHDs per storage account, storage account throttling, etc. Horray you say? Yes indeed, horray.
Next up, was what to do with them. I, like many of you, prefer to automate all of the things. There are a variety of great ways to automate and configure VM deployments with Managed Disks and the CLI, but something that was missing was the ability to do Managed Disks + Custom Image + ARM Template + Scale Sets deployment. Well, to be honest, it isn't missing, it's right there, just not at all documented yet. So here I am, your humble servant to provide the goodness that is the above scenario.
First, some references that helped me along the way.
- How do you work with Scale Sets in Managed Disks. Link
- How do you convert EXISTING ARM Templates to use Managed Disks. Link (I love reading pull requests haha)
- How do you create a generalized VM and capture it when you are using a Managed Disk (hint, it's not that different). Link
- I decided to make this fun, so I did it all with the new Azure CLI 2.0. Here are some of the changes I needed to make to my thinking. Link
- The mother load of all that is good with Managed Disks, along with a few gaps that need to be filled. Link
Ultimately, I needed just a few extra bits to make things go, but banged my head against the wall for a number of hours getting it all lined up. Here's where I landed:
- Get a VM in managed disks sysprepped / ready for capture. In my case, I used Premium Disks so when it is captured as an Image, it is Premium, so you can only deploy a Premium VM as a result.
- Once you have the VM shutdown, capture the VM as an image using the tool of your choice. Me, I just hit the CAPTURE button in the portal.
- Once captured, I had a disk image!
- Next, it was time to create and deploy my ARM template.
And here is the completed template: link
The key to this template is the line down on OSDisk that references the image. Remember, in managed disks, my image can be anywhere in the same subscription!!!
That did the trick - a quick template deployment later and I had 1000 VMs running my custom Windows image.