---
title: PowerShell Script for migrating Azure Classic to Azure Resource Manager
description: Read how the author has explained the PowerShell Script for migrating Azure Classic to Azure Resource Manager.
image: https://blog.e-zest.com/hubfs/PowerShell%20script%20for%20classic%20to%20ARM%20resource%20migration%20in%20Azure-290118.png
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [News](https://blog.e-zest.com/news)
- [Innovation](https://blog.e-zest.com/innovation)

# PowerShell Script for migrating Azure Classic to Azure Resource Manager

[Surbhi Agarwal](https://blog.e-zest.com/author/surbhi-agarwal)  Feb 01, 2019

[Powershell](https://blog.e-zest.com/topic/powershell) [Azure Powershell](https://blog.e-zest.com/topic/azure-powershell) [Azure Resource Manager](https://blog.e-zest.com/topic/azure-resource-manager)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager&text=PowerShell%20Script%20for%20migrating%20Azure%20Classic%20to%20Azure%20Resource%20Manager>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager>

First, install the latest version of Azure PowerShell. Ensure that you are an administrator for the subscription in Azure portal: To perform this migration, you must be added as a co-administrator for the subscription in the Azure portal.

**Perform the below steps to migrate:**

- Sign into the Azure portal.
- On the Hub menu, select Subscription. If you don't see it, select All Services.
- Find the appropriate subscription entry, then look at My Role field. For a co-administrator, the value should be Account admin.
- If you are not able to add a co-administrator, then contact a service administrator or co-administrator for the subscription to get yourself added.

**Below are the main steps to migrate from Azure Classic to Azure Resource Manager:**

**Set your subscription and sign up for migration:**

- First, start a PowerShell prompt. For migration, you need to set up your environment for both classic and Resource Manager.
- Sign in to your account for the Resource Manager model.
  
  *Connect-AzureRmAccount*
- Get the available subscriptions by using the following command:  
    
  *Get-AzureRMSubscription | Select SubscriptionName*
- Set your Azure subscription for the current session. This example sets the default subscription name to My Azure Subscription. Replace the example subscription name with your own.  
    
  *Select-AzureRmSubscription –SubscriptionName "My Azure Subscription"*

**Register with the migration resource provider by using the following command:**

*Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate*

**Please wait for few minutes for the registration to finish. You can check the status of the approval by using the following command:**

*Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate*

**Now sign in to your account for the classic model.**

*Add-AzureAccount*

- Get the available subscriptions by using the following command:
  
  *Get-AzureSubscription | Select SubscriptionName*
- Set your Azure subscription for the current session. This example sets the default subscription to My Azure Subscription. Replace the example subscription name with your own.
  
  *Select-AzureSubscription –SubscriptionName "My Azure Subscription"*

**Make sure you have enough Azure Resource Manager Virtual Machine vCPUs in the Azure region of your current deployment or VNET: You can use the following PowerShell command to check the current number of vCPUs you have in Azure Resource Manager.**

To learn more about vCPU quotas, see Limits and the Azure Resource Manager.

- This example checks the availability in the West US region. Replace the example region name with your own.  
    
  *Get-AzureRmVMUsage -Location "West US"*

**Run commands to migrate your IaaS resources:**

- Migrate VM’s in a cloud service (not in a virtual network)
- Migrate VM’s in a virtual network
- Migrate Account  
  Please note that you need to migrate virtual network first as the Virtual Machines associated to them will move together with them. Then next move the Storage accounts after migrating the virtual networks.
  
  To migrate virtual machines in a virtual network, you migrate the virtual network. The virtual machines automatically migrate with the virtual network. Pick the virtual network that you want to migrate.
- This example sets the virtual network name to myVnet. Replace the example virtual network name with your own.
  
  *$vnetName = "myVnet"*
- First, validate if you can migrate the virtual network by using the following command:
  
  *Move-AzureVirtualNetwork -Validate -VirtualNetworkName $vnetName*
- The following command displays any warnings and errors that block migration. If validation is successful, then you can proceed with the following Prepare step:
  
  *Move-AzureVirtualNetwork -Prepare -VirtualNetworkName $vnetName*
- Check the configuration for the prepared virtual machines by using either Azure PowerShell or the Azure portal. If you are not ready for migration and you want to go back to the old state, use the following command:
  
  *Move-AzureVirtualNetwork -Abort -VirtualNetworkName $vnetName*
- If the prepared configuration looks good, you can move forward and commit the resources by using the following command:
  
  *Move-AzureVirtualNetwork -Commit -VirtualNetworkName $vnetName*

**Once you're done migrating the virtual machines, we recommend you perform the following prerequisite checks before you migrate the storage accounts.**

Migrate classic virtual machines whose disks are stored in the storage account

*$storageAccountName = 'yourStorageAccountName'*

*Get-AzureDisk | where-Object {$\_.MediaLink.Host.Contains($storageAccountName)} | Select-Object -ExpandProperty AttachedTo -Property DiskName | Format-List -Property RoleName, DiskName*

The above command returns RoleName and DiskName properties of all the classic VM disks in the storage account.

RoleName is the name of the virtual machine to which a disk is attached. If this command returns disks, then ensure that virtual machines to which these disks are attached are migrated before migrating the storage account.

- Delete unattached classic VM disks stored in the storage account
- Find unattached classic VM disks in the storage account using following command:  
    
  *$storageAccountName = 'yourStorageAccountName'
  
  Get-AzureDisk | where-Object {$\_.MediaLink.Host.Contains($storageAccountName)} | Where-Object -Property AttachedTo -EQ $null | Format-List -Property DiskName*

- If above command returns disks, then delete these disks using the following command:
  
  *Remove-AzureDisk -DiskName 'yourDiskName'*
- Delete VM images stored in the storage account
- The following command returns all the VM images with OS disk stored in the storage account.
  
  *Get-AzureVmImage | Where-Object { $\_.OSDiskConfiguration.MediaLink -ne $null -and $\_.OSDiskConfiguration.MediaLink.Host.Contains($storageAccountName)\` } | Select-Object -Property ImageName, ImageLabel*
- The following command returns all the VM images with data disks stored in the storage account.  
  *Get-AzureVmImage | Where-Object {$\_.DataDiskConfigurations -ne $null -and ($\_.DataDiskConfigurations | Where-Object {$\_.MediaLink -ne $null -and $\_.MediaLink.Host.Contains($storageAccountName)}).Count -gt 0 } | Select-Object -Property ImageName, ImageLabel*
- Delete all the VM images returned by above commands using this command:
  
  *Remove-AzureVMImage -ImageName 'yourImageName'*
- Validate Storage Account and Start Migration
- Validate each storage account for migration by using the following command. In this example, the storage account name is myStorageAccount. Replace the example name with the name of your own storage account.  
    
  *$storageAccountName = "myStorageAccount"*  
  *Move-AzureStorageAccount -Validate -StorageAccountName $storageAccountName*
- Next step is to prepare the storage account for migration:
  
  *$storageAccountName = "myStorageAccount"*  
  *Move-AzureStorageAccount -Prepare -StorageAccountName $storageAccountName*
- Check the configuration for the prepared storage account by using either Azure PowerShell or the Azure portal. If you are not ready for migration and you want to go back to the old state, use the following command:
  
  *Move-AzureStorageAccount -Abort -StorageAccountName $storageAccountName*
- If the prepared configuration looks good, you can move forward and commit the resources by using the following command:
  
  *Move-AzureStorageAccount -Commit -StorageAccountName $storageAccountName*

 By now you would have successfully migrated from Azure classic to Azure Resource Manager. Hope this blog was helpful. Leave your thoughts in comments.

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager&text=PowerShell%20Script%20for%20migrating%20Azure%20Classic%20to%20Azure%20Resource%20Manager>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/powershell-script-for-migrating-azure-classic-to-azure-resource-manager&title=&summary=&source=>

### Similar Blog

[![PowerShell – Assigning Tags to Azure Resources using Excel Sheet](https://blog.e-zest.com/hubfs/Banners/PowerShell%20%E2%80%93%20Assign%20Tags%20to%20Azure%20Resources%20using%20Excel%20Sheet%20V2-08_2x.jpg) PowerShell – Assigning Tags to Azure Resources using Excel Sheet Prerequisite By Sourabh Majali Aug 03, 2023](https://blog.e-zest.com/powershell-assigning-tags-to-azure-resources-using-excel-sheet)

[![How to Enable Accelerated Networking on NICs – Azure Virtual Machine using PowerShell + Excel sheet](https://blog.e-zest.com/hubfs/Blog_Files/blog_image05_2x_2560x1334.jpg) How to Enable Accelerated Networking on NICs – Azure Virtual Machine using PowerShell + Excel sheet Accelerated Networking enables single root I/O virtualization (SR-IOV) to a VM, greatly improving its networking performance. ... By Sourabh Majali Jul 07, 2023](https://blog.e-zest.com/how-to-enable-accelerated-networking-on-nics-azure-virtual-machine-using-powershell-excel-sheet)

[![Connecting Windows host to Ansible Engine](https://blog.e-zest.com/hubfs/blog-files/Connecting%20Windows%20host%20to%20Ansible%20Engine-190118.png) Connecting Windows host to Ansible Engine Ansible is a very useful tool. It is an open source IT configuration management, orchestration and deployment tool. It is better ... By Surbhi Agarwal Feb 13, 2019](https://blog.e-zest.com/connecting-windows-host-to-ansible-engine)

[![Virtual Machine Scale Set in Azure Microsoft](https://blog.e-zest.com/hubfs/blog-files/virtual-machine-scale-set-in-azure-microsoft.jpg) Virtual Machine Scale Set in Azure Microsoft Virtual Machine Scale Set, an interesting service offered by Microsoft Azure, helps to create and manage a group of identical, ... By Surbhi Agarwal Jan 16, 2020](https://blog.e-zest.com/virtual-machine-scale-set-in-azure-microsoft)

[![Azure DevOps to build the CI/CD pipeline](https://blog.e-zest.com/hubfs/blog-files/azure-devops.png) Azure DevOps to build the CI/CD pipeline The purpose of this blog is to give you an overview of Azure DevOps and how it can be used to build the CI/CD pipeline (Visual ... By Surbhi Agarwal May 16, 2019](https://blog.e-zest.com/azure-devops-to-build-the-ci-cd-pipeline)

[![Connecting Windows host to Ansible Engine](https://blog.e-zest.com/hubfs/blog-files/Connecting%20Windows%20host%20to%20Ansible%20Engine-190118.png) Connecting Windows host to Ansible Engine Ansible is a very useful tool. It is an open source IT configuration management, orchestration and deployment tool. It is better ... By Surbhi Agarwal Feb 13, 2019](https://blog.e-zest.com/connecting-windows-host-to-ansible-engine)

[![How to deploy Azure Kubernetes Service (AKS)?](https://blog.e-zest.com/hubfs/kubernetes.png) How to deploy Azure Kubernetes Service (AKS)? There are several commonly used DevOps tools and Kubernetes is one of them. Kubernetes is a portable, extensible open-source ... By Surbhi Agarwal Feb 12, 2019](https://blog.e-zest.com/how-to-deploy-azure-kubernetes-service)

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.