Move Azure resource to another subscription with the Azure Cloud Shell

A couple of days ago I wanted to tidy up my Azure subscription and move the unneeded resources from my active subscription to my team’s subscription. At first I wanted to move a storage account, which I created a couple of years ago - needless to say that this was of type classic resource. The Azure portal now introduced a quite handy operation which can be used for many resources in order to move the resource either to another resource group or even to another subscription. Yeah I know what you think right now - AWESOME.


So as I hit the “Move” button in the Azure portal in order to move the account to another subscription I got the following error:


And there it was - the problem of classic resource type migrations. So I searched a bit and had the idea of doing all needed operations within the Azure Cloud Shell. So let’s start off by opening the shell and registering a migration resource provider and set up the preparations for the migration of the storage account.

azure provider register Microsoft.ClassicInfrastructureMigrate
azure provider show Microsoft.ClassicInfrastructureMigrate
azure config mode arm
azure storage account prepare-migration <storageAccountName>

After runnning the last command you should see something like this in the Azure Cloud Shell:


So now let’s do the migration by entering the following command which should lead to the following output:

azure storage account commit-migration <storageAccountName>


So we have migrated the storage account from type classic to resource manager type. And now we are good to go to move the storage account to another subscription. And as we already have our shell session open let’s do this via the cloud shell as well. Just enter the following command and make a note of the ID:

az resource show -g <resourceGroupName> -n <storageAccountName> --resource-type "Microsoft.Storage/storageAccounts" --query id


And now finally we can move the resource to the destination subscription with the following command:

az resource move --destination-group <resourceGroupName> --ids <resourceID> --destination-subscription-id <destinationSubscriptionID>


This command will take a while to complete, but if you watch the destination resource group you will likely see the following message “Moving resources” as the following illustration shows:


And when the command is completed successfully you have moved your storage account. Of course you are not limited to storage accounts only, but you can move almost any service in the ARM world between resource groups or subscription. If you want to know how to move another resource type, just give me short notice below or on Twitter and I will follow up on that! Cheers…