Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you replicate an azure virtual machine?

I need to install a few software on a virtual machine in order to test my application. It would take 2-3hours to set it up. Can I just replicate the virtual machine 3 times after that, so that I don't need to spend another 5 hours to install the software on the other 2 virtual machines?

like image 585
Ryan Avatar asked Jul 19 '13 10:07

Ryan


People also ask

Can I clone an Azure VM?

1 Answer. You can clone a Azure VM in multiple ways, VM Image Capture: If it is a Windows VM, then run sysprep for generalizing the windows installation. VM Disk Snapshot: You can create a snapshot of a VHD and then create a managed disk from the snapshot and deploy VM.

How does Azure VM replication work?

Replication processContinuous replication begins for the VM. Disk writes are immediately transferred to the cache storage account in the source location. Site Recovery processes the data in the cache, and sends it to the target storage account, or to the replica managed disks.

How do I enable replication in Azure VM?

To enable replication for an added disk, do the following: In the vault > Replicated Items, click the VM to which you added the disk. Click Disks, and then select the data disk for which you want to enable replication (these disks have a Not protected status). In Disk Details, click Enable replication.


2 Answers

Yes, you can use the capture capability to create a base image that you can then use to deploy other machines from. Take a look at these instructions: http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-capture-image-windows-server/.

This assumes you are referring to a Windows Server machine. Also, it assumes that a sysprep won't affect the software you have installed. If a sysprep will cause a problem them you also might be able to take a copy of the underlying VHD and spin up a different machine from the copy. Both methods are explained in this article here: http://community.adxstudio.com/blogs/shan/2012-06-28-cloning-windows-azure-virtual-machines/

like image 61
MikeWo Avatar answered Sep 19 '22 12:09

MikeWo


Yes you can, here is how I did it. I did not have to use PowerShell and my original VM still worked after.

Result if you use sysprep from documentation:

Once you have run sysprep on an VM it is considered generalized and it cannot be restarted. The process of generalizing a VM is not reversible. If you need to keep the original VM functioning, you should take a copy of the VM and generalize the copy.

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Fclassic%2Ftoc.json

Steps:

Start by copying a disk. Create a snapshot, then create a disk from the snapshot. This allows you to keep the original VHD as a fall back.

  1. In the left menu, click on All resources.
  2. In the All types drop-down, de-select Select all and then scroll down and select Disks to find the available disks.
  3. Click on the disk that you would like to use. The Overview page for the disk opens.
  4. In the Overview page, on the menu at the top, click + Create snapshot.
  5. Type a name for the snapshot.
  6. Choose a Resource group for the snapshot. You can either use an existing resource group or create a new one.
  7. Choose whether to use standard (HDD) or Premium (SDD) storage.
  8. When you are done, click Create to create the snapshot.
  9. Once the snapshot has been created, click on + Create a resource in the left menu.
  10. In the search bar, type managed disk and select Managed Disks from the list.
  11. On the Managed Disks page, click Create.
  12. Type a name for the disk.
  13. Choose a Resource group for the disk. You can either use an existing resource group or create a new one. This will also be the resource group where you create the VM from the disk.
  14. Choose whether to use standard (HDD) or Premium (SDD) storage.
  15. In Source type, make sure Snapshot is selected.
  16. In the Source snapshot drop-down, select the snapshot you want to use.
  17. Make any other adjustments as needed and then click Create to create the disk.

Create a VM from a disk Once you have the managed disk VHD that you want to use, you can create the VM in the portal.

  1. In the left menu, click on All resources.
  2. In the All types drop-down, de-select Select all and then scroll down and select Disks to find the available disks.
  3. Click on the disk that you would like to use. The Overview page for the disk opens. In the Overview page, make sure that DISK STATE is listed as Unattached. If it isn't, you might need to either detach the disk from the VM or delete the VM to free up the disk.
  4. In the menu at the top of the pane, click + Create VM.
  5. On the Basics page for the new VM, type in a name and select either an existing resource group or create a new one.
  6. On the Size page, select a VM size page and then click Select.
  7. On the Settings page, you can either let the portal create all new resources or you can select an existing Virtual network and Network security group. The portal always create a new NIC and public IP address for the new VM.
  8. Make any changes to the monitoring options and add any extensions as needed.
  9. When you are done, click OK.
  10. If the VM configuration passes validation, click OK to start the deployment.

I choose to create a new virtual network since the servers themselves did not need any local connections.

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-specialized-portal#copy-a-disk

like image 33
Ogglas Avatar answered Sep 20 '22 12:09

Ogglas