Monday, 13 March 2017

Migrate MSAzure VM Image from Classic to ARM portal

Migrate the Classic Image to ARM

First get the VM disks storage path.

OS disk : https://xxxx.blob.core.windows.net/vhds/PublicServer-os-2017-03-06-BC0F1E4.vhd
Disk 1 :-
https://xxxx.blob.core.windows.net/vhds/PublicServer-datadisk-0-2017-03-06-BC0F1E4.vhd

Disk 2 :
https://xxxx.blob.core.windows.net/vhds/PublicServer-datadisk-1-2017-03-06-BC0F1E4.vhd

In another ARM, Create a Storage & Container

New ARM Stroage account Name : magnatemplate


Container Name : https://template.blob.core.windows.net/temcon

Download & Install the Microsoft Azure Storage Explorer tool and add both the accounts in that tool and found the source disks & copy in to the destination disk


Create a VM from a specialized VHD disk using this https://azure.microsoft.com/en-us/resources/templates/201-vm-specialized-vhd/

and Click Deploy to Azure in ARM portal

Once VM has deployed, We need to create the image from that VM

using below link to make the sysprep and create a VM

https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-generalize-vhd?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json

Prerequisites to take the Image :

Log in to Azure PowerShell
Open Azure PowerShell and sign in to your Azure account.

Copy
PowerShell
 Login-AzureRmAccount
A pop-up window opens for you to enter your Azure account credentials.

Get the subscription IDs for your available subscriptions.

Copy
PowerShell
 Get-AzureRmSubscription
Set the correct subscription using the subscription ID.

Copy
PowerShell
 Select-AzureRmSubscription -SubscriptionId "<subscriptionID>"
Deallocate the VM and set the state to generalized
Deallocate the VM resources.

Copy
PowerShell
 Stop-AzureRmVM -ResourceGroupName <resourceGroup> -Name <vmName>
The Status for the VM in the Azure portal changes from Stopped to Stopped (deallocated).

Set the status of the virtual machine to Generalized.

Copy
PowerShell
 Set-AzureRmVm -ResourceGroupName <resourceGroup> -Name <vmName> -Generalized
Check the status of the VM. The OSState/generalized section for the VM should have the DisplayStatus set to VM generalized.

Copy
PowerShell
 $vm = Get-AzureRmVM -ResourceGroupName <resourceGroup> -Name <vmName> -Status
 $vm.Statuses

Command to create the image

 Save-AzureRmVMImage -ResourceGroupName -Singapore-ARM  -Name magnapritemplate -DestinationContainerName magnatemcon -VHDNamePrefix cis1 -Path C:\Users\xxx\Desktop\New folder\Filename.json

You can get the output :

OperationId :
Status : Succeeded

Once created the image, go back to ARM portal again and more services -> templates-> add template-> General information->mention some name there, then ARM template-> (Open Filename.json file which is copied in local drive and copy & paste) in to the arm template

click add..

Deploy a VM :

More Services -> templates -> click the template which we created and there click deploy options and start to deploy
..............