Move a VM from Azure Service Manager to Azure Resource Manager

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 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 and the native platform solution documented at

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 ( or an Azure server-side copy ( and

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 <vmname>-OS.vhd and data disk is <vmname>-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 -DnsServer 

# Add NIC to VM
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id

$osDiskName = $vmname+'_osDisk'
$osDiskCaching = 'ReadWrite'
$osDiskVhdUri = "https://$"+$vmname+"-OS.vhd"
$vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Windows -Caching $osDiskCaching

#Add a data disk
$dataDiskVhdUri = "https://$"+$vmname+"-Data.vhd"
$dataDiskName = $vmname+'_dataDisk'
$vm = Add-AzureRmVMDataDisk -VM $vm -Name $dataDiskName -Caching None -CreateOption Attach -DiskSizeInGB 1023 -VhdUri $dataDiskVhdUri

# Create Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vm 


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.