Hey Folks,
Hope you are doing great, Thought of posting this article, because of a recent experiance I had. We wanted to move a particular VM from one Vnet to another VM. So we thought of taking a down time and Get a disk snapshot and re-reploy the VM in the second VNet.
But, unfortuanly Azure threw and error saying.
And I noticed, VM is getting deployed but we cannot power it on. And When I dig deepeer I saw VM publisher information was easy.
I was able to find many articles mentioning about this, but all the articles shows how to deploy the VM in a vanila environment. So I had to a tweek this a little bit
So we had to follow the below process using poweshell.
Collocting the required information from source VM
$vm = Get-azvm -ResourceGroupName "AE-DEV-SONUS-RG" -Name AERibbonVM
$vm.plan
Setting up Basic VM Config for the New VM
$vmconfig = New-AzVMConfig -VMName ribbonTemp2 -VMSize Standard_B1ms
Create a disk from the snapshot
$snapshot = Get-AzSnapshot -ResourceGroupName "AE-DEV-SONUS-RG" -SnapshotName RibbonSnap
$diskconfig = New-AzDiskConfig -Location “Australia East” -SourceResourceId $snapshot.Id -CreateOption Copy
$newdisk = New-AzDisk -Disk $diskconfig -ResourceGroupName "AE-DEV-SONUS-RG" -DiskName "RibbonDisk02"
$vmconfig = New-AzVMConfig -VMName ribbonTemp2 -VMSize Standard_B1ms
$vmconfig = Set-AzVMOSDisk -VM $vmconfig -ManagedDiskId $newdisk.Id -CreateOption Attach -Linux
Get Avaible Virtual Networks
$vnet = Get-AzVirtualNetwork -Name "AE-DEV-SONUS-RG-vnet" -ResourceGroupName "AE-DEV-SONUS-RG"
$subnet = Get-AzVirtualNetworkSubnetConfig -Name default -VirtualNetwork $vnet
Creating NIC For the NEW VM
$vmnic = New-AzNetworkInterface -Name “Ribbon_nic2” -ResourceGroupName "AE-DEV-SONUS-RG" -Location “Australia East” -SubnetId $subnet.Id
$vmconfig = Add-AzVMNetworkInterface -VM $vmconfig -Id $vmnic.Id
Setting Up the publisher inforamtion
$vmConfig = Set-AzVMPlan -VM $vmConfig -Publisher "ribboncommunications" -Product "ribbon_sbc_swe-lite_vm" -Name "ribbon_sbc_swe-lite_vm_release"
Creating New VM
New-AzVM -VM $vmconfig -ResourceGroupName "AE-DEV-SONUS-RG" -Location “Australia East”
Hope this helps you. :)
Will this be same when we plan to migrate a vm from one subscription to another in a different tenant? Source VM is a linux centos.
ReplyDeleteI belive that wont be the case, This was when we had to move to a diffrent VNet, irrespetive of the subscription. if you taking a snapshot and moving the disk, it wont carry the plan information. and you wont be able to update them once the VM is provisioned, eventhough MS article says we can set the plan infromation. that did not worked for us
ReplyDelete