Azure VM complete replication - azure

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.

Related

Patching and Updating Virtual Machine ScaleSets

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.

Azure - VM Generalize

I write this question because I found only partial informations about my scenario.
In Azure to clone a VM, I need to deallocate and generalize, after I can create a lot of copy as many I would. The details that I didn't find are:
the VM generalized "cost" me in term of CORE ? After azure vm generalize , If I run azure vm list-usage the number of cores used decreased or not ?
if I generalize a VM with all users / groups / services configured (Apache, DB, etc.) in the same disk of VM, after generalize -> clone, I will find again this configurations in new cloned VMs ?
what are the parameters that I can change after generalization, ex. Availability Set, Network Security Group, Nic associated, etc. ?
Thanks
the VM generalized "cost" me in term of CORE ? If I run azure vm list-usage the number of cores used decreased or not ?
Yes, it costs you in the term of CORE. However, you don't need pay for the VM. You only need pay for the OS and date VHDs storage account. When you use vm list-usage, you will find the core CurrentValue does not change. When you delete the VM, the cores will be released.
I will find again this configurations in new cloned VMs
Yes, you could. Sysprep removes all your personal account information, among other things, and prepares the machine to be used as an image. More information please refer to this link. For a Linux VM, please refer to this link.
what are the parameters that I can change after generalization, ex.
Availability Set, Network Security Group, Nic associated, etc. ?
You could use the generalized VHD image to create any VMs. All of them you could associate to the new VM. More information about how to create a VM from a generalized VHD image please refer to this link.
VM's are billed according to their capacity, not on the basis of whether they are generalized or not, a vm and a vm created from generalized vm would cost the same (granted they are the same "size").
this question has nothing to do with azure, it's just a syprep. Azure adds nothing to this process.
Anything you would expect when creating a new VM.
you need to understand the basic concepts behind virtualization to understand what is going on there.
https://en.wikipedia.org/wiki/Virtualization

Can you move/copy Azure virtual machines to a different instance?

If I setup a server running my application on an azure instance, for example A1 can I later change the instance to D2?
I might want to experiment with a VM at a lower cost but then move to a higher performing machine at a later date without having to rebuild everything.
Yes, you can change the size of Azure VM on demand. Changing the size will trigger a machine reboot and if you're using a configuration with SSD temporary drive, the content of the SSD will get erased. Other than that, everything else will be left untouched.
Drew, the Principal PM in this area has a great blog here about this.
You can only resize a VM to another offering that does not have fundamentally different hardware. Since A-Series and D-Series VMs have similar hardware, you would be able to swap those two around. You would not be able to go from A-Series to G-Series though. In addition you need to look at VM availability per region if you want to swap to something only in certain areas, as well as look at if you are using an ASM or ARM VM.
If you have an existing VM, you can check what it can swap out with in the new portal under "Size" in the VM Settings.
This will allow you to reboot into a different machine type, however any temp storage will be erased as with any VM reboot. You just need to ensure you are storing your persistent data in external storage.
You can learn more about the VM size offerings here.

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.

Possible to keep two vhd's in sync on azure vm's

This is scenario than a specific technical question.
I have two azure vm's who run a web application in load balanced mode.
as per this article http://asheej.blogspot.in/2014/03/load-balancing-using-windows-azure.html
both virtual machines are attached an additional disk which stores images which are referred from web application hosted in vm's IIS.
Now What would be the best way to keep contents on two vm hard drives in sync.
For example, If i delete, add a data from vhd of first vm then that should also be affected on second vm.
Is there anything possible, probably using a common vhd for both machines which will take sync out of question.
Before going into solution , let me briefly touch base on the VM and disk relationship.
Typically a VM contains 3 Disks attached to them 1. OS Disk 2. Temporary Disk and 3.Data Disks. The VM will have lease on all these disks ,the only way to write into data disks is via the VM.
The C: Disk is persistent, meaning when the VM get rebooted the data in the disk is retained. But the D:\ is non persistent , when you reboot the disk will be fully wiped clean. So at any point in time the D:\ shouldn't be used to store any user data.
So writing a process to sync between two VM's just to keep pictures in sync is not very ideal. You might know this already , but wanted to set context for the choice of options provided below.
Your potential options are as follows
You can setup File Share using the new Azure File Service (In Preview) http://blogs.technet.com/b/uspartner_ts2team/archive/2014/06/09/setting-up-a-file-share-for-the-new-azure-file-service.aspx. This will be single source for all your images and you don't need to worry about syncing of files.
2.Store the images in the Azure Blob and access them from the application that's running in the VM http://blogs.msdn.com/b/yaohuang1/archive/2012/07/02/asp-net-web-api-and-azure-blob-storage.aspx and http://www.nickharris.net/2012/11/how-to-upload-an-image-to-windows-azure-storage-using-mobile-services/
3.Host another VM as a Webserver and host your images from there. Then the two VM's can refer the image. The cost here will be to hosting the VM.
The key point with all the 3 potential options there is no need sync the files in two different places , everything is in single place.
Edited based on new information:-
In your scenario hosting your files into VM is not the right approach. You should take the following into consideration even for the short term solution , if you are using Azure LB.
Azure Load Balancer uses a 5 tuple (source IP, source port, destination IP, destination port, protocol type) to calculate the hash that and map traffic to available servers and also the distribution is fairly random. So if you load balance the VM, you cannot control which VM the images are accessed.
Manual updates is not possible in this scenario.
You either need to setup an virtual network to allow you to create and share a windows file share OR you should investigate the use of Azure File Service for creating a share that both VMs connect to (see: http://blogs.technet.com/b/uspartner_ts2team/archive/2014/06/09/setting-up-a-file-share-for-the-new-azure-file-service.aspx).

Resources