Autoscaling using custom image
With recent announcements like Managed Disks and Images, I thought it would be cool to put a script together. It will provision a VM Scaleset using a custom image that is captured from an existing server with existing applications and add autoscaling to it!
The general steps are to
take a copy of the existing virtual machine. I use Azure Storage Explorer as my favourite tool.
run sysprep and generalise it. "Sysprep /generalize /shutdown /oobe"
run the powershell to set it generalise.
Set-AzureRmVm -ResourceGroupName $rgName -Name $vm.Name Generalized
In Azure Portal, Images, create a new image pointing it to the generalised VM.
in Azure Portal, Templates (Preview), add the attached custom deployment template and deploy it
Once the VM Scaleset is provisioned, you can see the Overview for the autoscaling information.
RDP into the VM using the public IP address shown but set the port to 50000.
Then download a CPU Stress tool and run it. After a few minutes, autoscaling will provision more instances.
This is a POC script so feel free to modify it.
Let me know if you have any questions.
-- I-van;
Comments
- Anonymous
February 28, 2017
Would not generalized image will require new server to spend time at start up on OOBE? - Anonymous
February 28, 2017
Hi GS,In my case upon logging in first time it took less than 10 seconds. I chose to run on the smallest DS_v2 and Managed Premium disks for performance. You are welcome to do the same test which doesn't take long and share your experience. Best practice as per our guide is to generalise along with OOBE. This applies when I specifically chose to use the new Images associated with Managed Disks. https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-generalize-vhd?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json