0

I have one VM with a daily backup scheduled. Today I deleted a file in that VM and changed some configuration. I restored yesterday's data disk from my recovery service vault and changed the names of the recovered data disk.

Now I want to attach yesterday's restored backup to my existing VM. Is it possible?

If not then suppose I delete my VM but I keep its network interface card. I can create a new VM from restored VHDs using ARM templates but how can I assign an existing NIC to my new VM?

Also, I have added this VM to my domain controller. If I recreate the VM, do I need to add the new VM to the domain controller or will it work normally?

sirdank
  • 3,351
  • 3
  • 25
  • 58
Abhishek kumar
  • 81
  • 1
  • 11

1 Answers1

1

Now I want to attach yesterday's restored backup to my existing VM. is it possible?

Yes, we can attach this restore disk to your existing VM, then we can find the disk in your existing VM. enter image description here enter image description here

I delete VM but I keep network interface card for the VM, now I can create VM from restored VHD's using ARM templates but how to assign exiting NIC in the new VM?

Yes, we can use PowerShell to create a VM with existing NIC and VHD, here is 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 VM do I need to add new VM to domain controller or will it work normally?

Yes, the new create VM (restore) will add to the domain controller, we don't need to add the VM to domain controller again.

Jason Ye
  • 13,710
  • 2
  • 16
  • 25
  • +1 for your explanation but one question here, after you attach the restored OS disk it came as F drive so how we will delete existing c drive and replace this F drive as C drive. In short I want day before yerterday's OS disk and delete current OS disk. I found links that is only for creating VM from restored disk or but I want to keep the VM and just change the OS disk of that VM. – Abhishek kumar Apr 11 '17 at 07:52
  • 1
    @Abhishekkumar if you want to switch OS disk, I think we should use restore VM, or use this VHD to create a new VM with this existing NIC. – Jason Ye Apr 11 '17 at 07:55
  • @Abhishekkumar for use the same IP, I think we can use PowerShell to create another VM with this existing NIC. – Jason Ye Apr 11 '17 at 07:57
  • Yes I think this is the only option which I have, I need to create VM from restored disk and using same NIC. For this I need to delete current VM first to release the NIC and then create VM using that NIC while doing this there will downtime that is what my concern here. – Abhishek kumar Apr 11 '17 at 08:03
  • @Abhishekkumar there will downtime:(, does your Public static? – Jason Ye Apr 11 '17 at 08:06
  • @Abhishekkumar If your Public IP address is static, maybe we can restore this VM with `create a new VM`, after it complete, associate this public IP address to this new VM. this VM name same as your original VM, and in the same domain. in this way, we can reduce the downtime. – Jason Ye Apr 11 '17 at 08:16
  • I am not using public IP address for this VM. It is having private IP as Static. I have one VM which is serving as Jump server that contains public IP and from that VM I do RDP to this VM using private IP. As per my understanding if I assign that NIC at the time of creating new VM it will work. Let me try with the Powershell commands which you have mentioned above. your answer helped me 80% so I am marking this as an answer. – Abhishek kumar Apr 11 '17 at 09:10