Move a VM from Azure Service Manager to Azure Resource Manager

Learn ways to migrate from ASM to ARM.

John Savill

August 13, 2016

2 Min Read
Move a VM from Azure Service Manager to Azure Resource Manager

Q. How can I move a VM from Azure Service Manager to Azure Resource Manager?

A. Microsoft have a tool available at https://blogs.msdn.microsoft.com/tomholl/2016/07/16/migrating-azure-iaas-solutions-from-asm-to-arm-using-migaz/ which enables you to select the resources in ASM that you wish to migrate and it creates a JSON template that represents a "new" version of those objects in ARM. It also creates a BlobCopy.ps1 file which will copy the page blobs containing the VHDs used by the VMs to the newly created storage accounts. It's a great idea and is easy to use. There is also the asm2arm solution at https://github.com/fullscale180/asm2arm and the native platform solution documented at https://azure.microsoft.com/en-us/blog/iaas-migration-classic-resource-manager/.

If you wanted to do this manually using PowerShell you could manually copy the VHDs from the ASM storage account to an ARM storage account using Azure Storage Explorer (http://storageexplorer.com/) or an Azure server-side copy (http://windowsitpro.com/azure/copy-content-one-azure-storage-account-another and http://windowsitpro.com/azure/retrieve-storage-context-arm).

Once the VHD has been copied to an ARM storage account a new VM can be created on an ARM virtual network using the copied VHD files. For example (assumes OS disk is -OS.vhd and data disk is -Data.vhd (change as required):

#Resource Group name, VM size and name for new VM$rgname = 'RGSCUSInfra'$vmsize = 'Standard_A2'$vmname = 'savazudc01'#Network to connect to$virtnetname = 'VNet115'# Storage account (assumed to be in same Resource Group as the target for VM)$stoname = 'sascusgrsinfra'#location to create new VM$loc = 'SouthCentralUS' #Get the storage account$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;# Create VM Object$vm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize# Setup Networking$vnet = Get-AzureRmVirtualNetwork -Name $virtnetname -ResourceGroupName $rgname$subnetId = $vnet.Subnets[0].Id #Attach the VM to the first subnet$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $vmname) -ResourceGroupName $rgname `-Location $loc -SubnetId $subnetId # if wanted static IP and DNS add -PrivateIpAddress 10.7.115.13 -DnsServer 10.7.115.13 # Add NIC to VM$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id$osDiskName = $vmname+'_osDisk'$osDiskCaching = 'ReadWrite'$osDiskVhdUri = "https://$stoname.blob.core.windows.net/vhds/"+$vmname+"-OS.vhd"$vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Windows -Caching $osDiskCaching#Add a data disk$dataDiskVhdUri = "https://$stoname.blob.core.windows.net/vhds/"+$vmname+"-Data.vhd"$dataDiskName = $vmname+'_dataDisk'$vm = Add-AzureRmVMDataDisk -VM $vm -Name $dataDiskName -Caching None -CreateOption Attach -DiskSizeInGB 1023 -VhdUri $dataDiskVhdUri# Create Virtual MachineNew-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vm 

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like