Attaching the recovered OS disk to an existing virtual machine

I have one virtual machine with scheduled daily backups. Today I deleted a file in this VM and changed some configuration. I restored the data drive yesterday from my recovery service vault and changed the names of the recovered data drive.

Now I want to link yesterday's restored backup to my existing virtual machine. Is it possible?

If not, let's say I delete my virtual machine, but I keep its network interface card. I can create a new VM from recovered VHDs using ARM templates, but how can I assign an existing NIC to my new VM?

Also, I added this VM to a domain controller. If I recreate the virtual machine, do I need to add the new virtual machine to the domain controller, or will it work fine?

0


source to share


1 answer


Now I want to link yesterday's restored backup to my existing virtual machine. is it possible?

Yes, we can connect this recovery disk to an existing virtual machine, after which we will find the disk in your existing virtual machine. enter image description here enter image description here

I delete the VM, but I keep the NIC card for the VM, I can now create a VM from the recovered VHD using ARM templates, but how do I schedule the NIC out of the new VM?

Yes, we can use PowerShell to create a virtual machine with existing NICs and VHDs, here's an example:



$rgname = "jason-newgroup" 
$loc = "japaneast" 
$vmsize = "Standard_DS1_v2" 
$vmname = "jason-newtest2" 
$vm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize 
$nic = Get-AzureRmNetworkInterface -Name "NICname" -ResourceGroupName $rgname 
$nicId = $nic.Id 
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nicId 
$osDiskName = "jason-newtest" 
$osDiskVhdUri = "https://jasonnewgroupdisks912.blob.core.windows.net/vhds/jason-newtest201681285042.vhd" 
$vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Windows 
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vm 

      

If I recreate the virtual machine, do I need to add the new virtual machine to the domain controller, or will it work fine?

Yes, the newly created VM (restore) will be added to the domain controller, we don't need to add the VM to the domain controller again.

+1


source







All Articles