In Azure we have two deployment methods, ASM (Azure Service Manager) aka classic & ARM (Azure Resource Manager). When the beginning of Azure we use ASM model to deploy resources and manage our cloud infrastructure but soon Azure team realize we need a better more robust management and deployment infrastructure for azure. So beginning of 2015 they introduce the new model ARM and gradually they migrate resources support from ASM to ARM. But the question we face is how we migrate resources we deployed in to ASM to ARM, we just can’t migrate them because both are two separate models and have different API calls. So from today’s post I’ll walk-through how we can migrate IaaS infrastructure from ASM to ARM.
Before migrating resources refer supported and unsupported features and configurations to verify which resources are support for migration.
So first step is to login to Azure ARM & ASM model using PowerShell
#Login Azure ARM Login-AzureRmAccount #Login Azure ASM Add-AzureAccount #Select Azure Subscription Select-AzureRmSubscription -SubscriptionId <SubscriptionID> Select-AzureSubscription -SubscriptionId <SubscriptionID> -Current
Next we had to register the migration resources for migration
#Register Migration Resources Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate #Verify Migration Resources are registered Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate
After register the resource wait for five minutes to complete the registering, if its success it shows as bellow
In this post migrating a virtual machine that attached to VNET if you’re migrating any other resource(cloud service) refer this documentation.
The easiest way to migrate a VM attached in to VNET is to migrate the VNET, When we migrate VNET it migrate the VM to the ARM model.
It’s a three-step first we have to validate the resources are valid for migration and it will give any errors or warnings if there any.
#Migrate VM in a VNET $vnetName = "asmmig" #Validate the VNET for Migration $validateMessage = Move-AzureVirtualNetwork -Validate -VirtualNetworkName $vnetName [12:44:40 PM] KRR C:\> $validateMessage.ValidationMessages ResourceType : VirtualNetwork ResourceName : asmmig Category : Information Message : Virtual Network asmmig is eligible for migration. VirtualMachineName : ResourceType : Deployment ResourceName : web01 Category : Information Message : Deployment web01 in Cloud Service asmmigkasun is eligible for migration. VirtualMachineName : ResourceType : Deployment ResourceName : web01 Category : Information Message : VM web01 in Deployment web01 within Cloud Service asmmigkasun is eligible for migration. VirtualMachineName : web01 ResourceType : Deployment ResourceName : web01 Category : Warning Message : VM web01 in HostedService asmmigkasun contains Extension BGInfo version 1.* which is an XML extension. XML extensions are not supported in Azure Resource Manager. It is recommended to uninstall it from the VM. Alternatively, it will be automatically uninstalled during migration. VirtualMachineName : web01
Next we have to prepare for migration
#Prepare for migration $prepareMessage = Move-AzureVirtualNetwork -Prepare -VirtualNetworkName $vnetName
When this command execute you will see resources are moving from ASM to ARM as follows
In this it only migrate VM and VNET only we have to migrate Storage account separately.
Next we have to commit the migration
#commit the Migration $commitMessage = Move-AzureVirtualNetwork -Commit -VirtualNetworkName $vnetName
Next we need to migrate the storage from ASM to ARM
Before migrating we need to few prerequisites to verify the VM disks are moved
#Migrate Storage Account ------------------------------------------------------------------------------------ #Prerequist Checks $storageAccountName = 'armmig' Get-AzureDisk | where-Object {$_.MediaLink.Host.Contains($storageAccountName)} | Select-Object -ExpandProperty AttachedTo -Property ` DiskName | Format-List -Property RoleName, DiskName #Delete Unattached classic VM disk in storage Account (If Exists from above command) $classicVMDiskName = Get-AzureDisk | where-Object {$_.MediaLink.Host.Contains($storageAccountName)} | Format-List -Property DiskName Remove-AzureDisk -DiskName 'DiskName' #Delete VM Images Get-AzureVmImage | Where-Object { $_.OSDiskConfiguration.MediaLink -ne $null -and $_.OSDiskConfiguration.MediaLink.Host.Contains($storageAccountName)} | Select-Object -Property ImageName, ImageLabel Remove-AzureVMImage -ImageName 'yourImageName' #If output from above command
Next we have to repeate the same steps as VNET migration
#prepare moving storage account $prepareStorageMsg = Move-AzureStorageAccount -Prepare -StorageAccountName $storageAccountName #commit the storage migration $commitStorageMsg = Move-AzureStorageAccount -Commit -StorageAccountName $storageAccountName
After this commands you will see the storage account is migrated to ARM as bellow
Now you can see resources are in 3 resource groups so its little hard to manage when same infrastructure resources are in different RG so we can move those resources to one RG as follows.
After move we can see as below.