Patching and Updating Virtual Machine ScaleSets - azure

As I understand, Virtual Machine Scale Sets are a collection of Virtual Machines. Each one can be destroyed and reconstituted at the whim of the configuration. The VM's are recreated from a certain image. Is this understanding is correct ?
If this is correct, how do you patch a scaleset ?
Consider a scaleset created using a Windows 2016. 50 patches are made available via the update service since the base image was created. During a heavy load, 3 new VMs are created by the scaleset. The new VMs should load 50 patches before even going on-line. That could take hours. The patches might not work at all.
What is the best practice to handle this issue ?

I would like to suggest to create the VMSS from a custom image. You could first deploy a windows 2016 and install the 50 patches, then make this as a custom VM image. This custom VM image includes any required application installs or configurations. Any VM instances created in the scale set use the custom VM image and are ready to serve your application traffic. In this tutorial you learn how to:
Create and customize a VM
Deprovision and generalize the VM
Create a custom VM image
Deploy a scale set that uses the custom VM image
You could make it with multiple methods.
Tutorial: Create and use a custom image for virtual machine scale sets with Azure PowerShell
Tutorial: Create and use a custom image for virtual machine scale sets with the Azure CLI
Add a custom image to an Azure scale set template

The Windows Server images in the marketplace are continually updated (at roughly a monthly cadence) with all of the latest patches. Installing the latest version is a good starting point to keep your instances up-to-date.
In order to stay up-to-date on existing instances when new images are released, you can enable automatic OS image upgrades, which will safely update instances in a rolling fashion when a new version of the image is available.

Related

sync files between azure scale set vms

i am a newbie and am planning to host iis server for my client in azure with auto-scale functionality.
we will test modules and update once in a week in iis server, my question is how to sync the files between vms while on auto-scaling and if we can use auto-scale only for identicals vms, then please suggest me the solution for this scenario. we will start min 2 max 10 vms in auto-scale.
Regards,
Kumar B
I first would ask why a VM, things do get more complicated using VMs. Scale Set would help support this however you still will have issues when you want to deploy new code. You said IIS so I am presuming Windows. Desired State Configuration is a great choice you can make a PowerShell script that will "configure" your VM for you, and potentially pull in any code updates. This is also where things like chef/puppet/salt can come into play to ensure the server is configured.
You could look at creating a custom image that every time you deploy new code gets baked into the image. Then you are basically doing a rolling update where you spin up a new server and then destroy one until they all have been updated. Technically this could be done, either way, just if they are baked into the image you would have a quicker start time.
https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-deploy-app
https://adamtheautomator.com/azure-vm-scale-sets-powershell/
Automatic - VMs may be rebooted in a random order even taking all VMs temporarily down at the same time.
Rolling - The scale set deploys updates to instances in batches with an optional pause time between batches.
Manual - Nothing happens to existing VMs when an update is initiated.
What files are you trying to sync if they are not code files, Azure Files would be a great fit as that supports SMB or you could just use cloud storage.
You can deploy your application to a virtual machine scale set using desired state configuration. See: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-deploy-app
Not what you asked, but you should consider why you are hosting your app in IIS on VMs. If you are using Azure, then Azure App Service may be a better fit. See: https://learn.microsoft.com/en-us/azure/app-service/

Azure VM complete replication

I have a azure vm setup that contains custom software, files, folders blah blah. At any point I will need to create multiple identical instances of the existing vm (maybe up to 30). I used the sysprep in the vm, in the azure portal I used the capture image for the vm and tried to create a new VM from the image. The new vm created from the image did not contain any of the files from the previous vm.
What would be the best approach in preserving a complete image of the vm and be able to mass deploy from it at any given time?
I'm not sure what you do makes the file disappear, but on my side, it works well. Sysprep just removes all your personal account and security information and then prepares the machine to be used as an image. You can see the feathers of it from Sysprep overview.
To create a custom VM image, see Create a managed image of a generalized VM in Azure. I suggest that creating an image directly from the VM ensures that the image includes all of the disks associated with the VM, including the OS disk and any data disks.
For the creation of multiple identical instances, you can use the Azure VM Scale Sets. The VMs are identical, load balanced in a group, so if you want to specialize one of them, you need to specialize all of them through a custom image.
Also, you can use the Azure Template to create multiple individual VMs, they are ไป–the independent VMs, you can specialize any one of them, not all of them, but uniform management is a little difficult.
You can get more details about the difference between them, see Differences between virtual machines and scale sets.

How to get a list of compatible vm sizes for deploy in the same cloud service?

I have a single cloud service in Azure that contains one VM. I would like to deploy another virtual machine.
What is the api to get a list of compatible vm sizes for deploy in the same cloud service?
I don't want to have the following exception:
Hyak.Common.CloudException: Compute.CannotUpgradeDeploymentToNewRoleSize : Unable to upgrade the deployment. The requested VM size 'Standard_D4' may not be available in the resources supporting the existing deployment. ..
#ivan_petrushenko, I think the API you want to get a list of compatible vm sizes for deploy in the same cloud service is the one of the list below.
List available VM sizes in an availability set
List available VM sizes in a region
List all available virtual machine sizes for resizing
And according to the troubleshooting for resizing an existing VM, you can try to stop the VM first, then to start to resize the VM.
As references, there is a similar thread from ServerFault that the answerer has a blog introduced the VM size change considerations. Meanwhile, a blog from a MS partner shows the tables about all the resizing configuration paths.
Update:
The section Allocation scenario: Resize a VM or add VMs or role instances to an existing cloud service explained your issue.

how can I configure availability sets in azure?

I am not very familiar with this in azure.
I created one centos vm, I created an availability set, in order to enable auto scaling I need to create another VM in the same availability set.
so I will create another vm, with the same image.
So, these 2 vms will replicate each other? if I install something in one VM, will it be replicated automatically to the other vm?, should I use only one of the vms as the starter point to install and configure things?
or should I do everything manually on each VM? Example, if I open port 80 in one I should do it in another?, if I install magento in one, I should install it in the other?
Azure will not replicate your VMs automatically. There are some manual steps involved:
You need to prepare one VM as a starter point.
Then you manually clone VMs up to a maximum number that you will need.
Make sure all they are in the same availability set.
Set up auto scaling
Now Azure will scale automatically by turning some of your VMs on and off. When VM is turned off, you will only incur storage costs for it. And storage in Azure is almost free.
To answer your first question: How to configure availability set
I created a post covering this on How to guard your application from azure outages
Use the quick create to stand up a VM of your choice
Once the instance is running click on the configure tab and create a new availability set
Click save
Saving will force a shut down, reconfigure, startup process
Once the VM comes back online you can create a 2nd VM
Using the create from gallery option, click through all the create screens until you get to the configure virtual machine screen (screen 4 at the moment)
Select the cloud service that was created with your first VM (availability sets require the VM's to run in the same cloud service)
Then select the availability set you created for the first VM
Finish the creation of your second VM
You can now see the linked VM's in the same availability set by clicking on the configure tab for any VM in the availability set you created. It will list all VMs in a given availability set inside the details of the VM

How to add a current VM to another cloud service without having to rebuild the vm in Azure?

We have a few servers in Azure that are running the same service. We would like them to be part of the same availability set. How do you add these servers together in the same availability set if they were not created in the same cloud service when they were created?
It looks like I would need to rebuild these VM's? If so that kinda sucks.
Please let me know if anyone knows a better way.
Thanks in advance.
Once a VM is created, it can't join an availability set.
However, the image for the VM is available in storage. So, new VMs can be spun up, using the image, this time adding them to the set. And rebuilding the VM from scratch is not needed.
Edit:
I've used the method above to bring up a VM, but I had forgotten that if your VM is running already, capture is the way to go. I'd suggest these steps:
Capture the image of your current VM. This will run sysprep on it, so you will want to be careful with it. (spin up a test VM and play with the steps until you feel confident to move to a production box)
Then when you create a new VM, specify your captured image and your availability set. Then the machine will come up with all your services running in the new set.

Resources