How to move Azure VM between subscriptions


I recently needed to move an Azure Virtual Machine from one subscription to another one. I read a LOT on how to do that and it looks super complicated. At the end of the day, I found an easy 3 steps way to make it, so sharing on this blog Sourire

Step 1: Move the Azure VM from one Blob storage to another one

In Microsoft Azure, when you have a blob  storage, it can be attached only to 1 subscription. You can of course have multiple storage attached into a subscription. So first step is to move the VHD which is used by the VM.

For this, I used the excellent CloudBerry Explorer for Azure which you can download for free here. After installation, just register for free and you’re good to go.

You’ll need to add your 2 blob storage, the one you want to move the VHD from and the one you want to move the VHD to.

image

To find the name of the storage and the key, just go into the Azure management console and select Manage Access Keys, you’ll get the info you need to setup both accounts.

image

Once setup, you can now have a view like this:

image

Stop your VM and you’re good to copy/paste your VM from one storage to another.

Step 2: Create a Disk from VHD

In the management console, go to Virtual Machine then Disks

image

then Create

image

fill a name, select the VHD from the storage you just moved your VHD file to.

image

Step 3: Create the VM from the Disk

Go to the Virtual Machine instances

image

then create a New

image

select From Gallery

image

and go to Disks to select the disk you just created.

image

And you’re good to go to run your VM!


Comments (21)

  1. Ruud Borst says:

    Very nice, thanks for sharing. I assume the data transfer part occurs between Azure and your client computer and from there again into Azure?

  2. Laurelle says:

    It's moved directly. If you want, you can move them to your PC as well.

  3. Vinicius Paluch says:

    Much Easier is impossible!  thanks!

  4. John T says:

    Will this work for moving a VM from the Service Management platform to the Resource Manager platform?

  5. Iain L says:

    when I attempt to copy a VM the copy option is not selectable?

  6. Joakim says:

    Too bad this is only for the classic VM's and the old portal... How is this done in the new portal and with the new Resource Management?

    1. Abinesh says:

      Try Azure storage explorer for ARM vm's.

  7. Emre Aydin says:

    After register storage accaount create a container to new storage. And then you can be able to copy/move your vHDs in it.

    Emre Aydin

    emre.aydin@mshowto.org

    MSHOWTO.ORG

    1. David Ma MS says:

      With the new Azure portal, how to create disks from vhd. thanks

  8. Juha Metsäkallas says:

    Hello!

    I've assembled a virtual machine (VM) using the Azure Service Management (ASM) a.k.a. Classic deployment model. This VM encompasses AD (it is a Domain Controller), MS SQL Server and Sharepoint 2013. Yes, I know, that is an unsupported (by Microsoft) set-up for Sharepoint, but I have had it working as a development environment. Previously I have cloned it with Powershell but MS made some changes and instead of updating the scripts I tested with the way above.

    The cloning works, Sharepoint works except Office add-ins (previously known as apps). I have hunted down the issue to nslookup. A working VM responds

    c:\nslookup
    Default Server: localhost
    Address: 127.0.0.1

    while non-working VM responds

    c:\nslookup
    Default Server: UnKnown
    Address: 100.108.26.5

    where the first three fields of the address are the same as a DHCP generated address for the server's internal IP.

    I repeat, the VM has worked previously. The only difference is that when cloned with Powershell it keeps working, when with Cloudberry + Azure gallery, nslookup quits to work.

  9. The Copy paste or Move option is disabled in CloudBerry Explorer when i am trying to copy the container form "Move From" to "Move To" storage. why would that be disabled?

    1. Bobby says:

      I have the same challenge. I do not see the copy and paste options enabled in my setup.

  10. Santhosh Katta says:

    Hi,
    Thanks for your post. When i am trying to move vhd from one blob to another blob, getting the following error.

    "There is currently a lease on the blob and no lease ID was specified in the request..."
    I deleted the entire VM from the subscription. So could please help me on this. What is this "ID" and how to get that. Thanks

  11. George says:

    I used Azure Management Studio instead, as the Copy option was not selectable in Cloudberry, and it worked just fine, thanks!

  12. Gulab Pasha says:

    Hi Guys,

    I read the article, it is very nice. I'm looking for the powershell script to move VM's (OSDisk) from one account to another (one Subscripton to another) and also I'm looking for hardware upgrade and downgrade size of the VM's without powering off.

    I'm very much new to Azure and I would like to move my Linux VM's from one Subscription to another.

    Looking forward to your support.

    Thanks,
    Gulab Pasha

  13. Gulab Pasha says:

    Hi Guys,

    Sorry if it is a off topic question, I’m trying to move complete resource group to another subscription and get the following error, where as I have granted ownership for both accounts to the resource group (Source and Destination). Move includes VM, Storage Accounts, Networks & Public IP’s.

    PowerShell Script:
    ----------------------------
    $gulab=Login-AzureRmAccount
    $gulab=Get-AzureRmSubscription -SubscriptionId “My_Subscription_ID”

    $webapp = Get-AzureRmResource -ResourceGroupName ‘Source_ResourceGroup_Name’ -ResourceName Source_VM_Name

    $plan = Get-AzureRmResource -ResourceGroupName Source_ResourceGroup_Name -ResourceName Destination_VM_Name

    Move-AzureRmResource -DestinationResourceGroupName Destination_ResourceGroup_Name -ResourceId $webapp.ResourceId -DestinationSubscriptionId “Another_Subscription_ID”

    Error:
    -------

    Get-AzureRmResource : ResourceGroupNotFound : Resource group ‘Destination_ResourceGroup_Name’ could not be found.

    At line:12 char:9

    + $plan = Get-AzureRmResource -ResourceGroupName Destination_ResourceGroup_Name -Resourc …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : CloseError: (:) [Get-AzureRmResource], ErrorResponseMessageException
    + FullyQualifiedErrorId : ResourceGroupNotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceCmdlet

    Move-AzureRmResource : MissingRegistrationsForTypes : The subscription ‘new_subscription_id’ is not registered for resource types
    ‘Microsoft.Compute/virtualMachines (southeastasia)’.

    At line:13 char:1

    + Move-AzureRmResource -DestinationResourceGroupName Destination_ResourceGroup_Name -Res …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : CloseError: (:) [Move-AzureRmResource], ErrorResponseMessageException
    + FullyQualifiedErrorId :

    MissingRegistrationsForTypes,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.MoveAzureResourceCommand
    ===================================================================================================================================

    Destionation_Subscription = Resource providers and types:
    ---------------------------------------------------------

    $gulabs=Get-AzureRmSubscription -SubscriptionId "My_Subscription_ID"

    Get-AzureRmResourceProvider

    ProviderNamespace : Microsoft.ClassicStorage
    RegistrationState : Registered
    ResourceTypes : {storageAccounts, quotas, checkStorageAccountAvailability, storageAccounts/services...}
    Locations : {East Asia, Southeast Asia, East US, East US 2...}

    ProviderNamespace : Microsoft.ClassicInfrastructureMigrate
    RegistrationState : Registered
    ResourceTypes : {classicInfrastructureResources}
    Locations : {East Asia, Southeast Asia, East US, East US 2...}

    ProviderNamespace : Microsoft.Compute
    RegistrationState : Registered
    ResourceTypes : {availabilitySets, virtualMachines, virtualMachines/extensions, virtualMachineScaleSets...}
    Locations : {East US, East US 2, West US, Central US...}

    ProviderNamespace : Microsoft.Network
    RegistrationState : Registered
    ResourceTypes : {virtualNetworks, publicIPAddresses, networkInterfaces, loadBalancers...}
    Locations : {West US, East US, North Europe, West Europe...}

    ProviderNamespace : Microsoft.ResourceHealth
    RegistrationState : Registered
    ResourceTypes : {availabilityStatuses, operations}
    Locations : {}

    ProviderNamespace : Microsoft.Storage
    RegistrationState : Registered
    ResourceTypes : {storageAccounts, operations, storageAccounts/listAccountSas, usages...}
    Locations : {East US, East US 2, West US, West Europe...}

    ProviderNamespace : Microsoft.ADHybridHealthService
    RegistrationState : Registered
    ResourceTypes : {services, addsservices, configuration, operations...}
    Locations : {West US}

    ProviderNamespace : Microsoft.Authorization
    RegistrationState : Registered
    ResourceTypes : {roleAssignments, roleDefinitions, classicAdministrators, permissions...}
    Locations : {}

    ProviderNamespace : Microsoft.Features
    RegistrationState : Registered
    ResourceTypes : {features, providers, operations}
    Locations : {}

    ProviderNamespace : Microsoft.Resources
    RegistrationState : Registered
    ResourceTypes : {tenants, locations, providers, checkresourcename...}
    Locations : {Central US, East Asia, Southeast Asia, East US...}

    ProviderNamespace : microsoft.support
    RegistrationState : Registered
    ResourceTypes : {operations, supporttickets}
    Locations : {North Central US, South Central US, Central US, West Europe...}

    PS C:\Windows\system32>

    ###################################################################################################

    Source_Subscription = Resource providers and types:
    ---------------------------------------------------

    $varun=Login-AzureRmAccount

    $varuns=Get-AzureRmSubscription -SubscriptionId "My_Another_Subscrition_ID"

    Get-AzureRmResourceProvider

    ProviderNamespace : Microsoft.ClassicStorage
    RegistrationState : Registered
    ResourceTypes : {storageAccounts, quotas, checkStorageAccountAvailability, storageAccounts/services...}
    Locations : {East Asia, Southeast Asia, East US, East US 2...}

    ProviderNamespace : Microsoft.ClassicInfrastructureMigrate
    RegistrationState : Registered
    ResourceTypes : {classicInfrastructureResources}
    Locations : {East Asia, Southeast Asia, East US, East US 2...}

    ProviderNamespace : Microsoft.Compute
    RegistrationState : Registered
    ResourceTypes : {availabilitySets, virtualMachines, virtualMachines/extensions, virtualMachineScaleSets...}
    Locations : {East US, East US 2, West US, Central US...}

    ProviderNamespace : Microsoft.Network
    RegistrationState : Registered
    ResourceTypes : {virtualNetworks, publicIPAddresses, networkInterfaces, loadBalancers...}
    Locations : {West US, East US, North Europe, West Europe...}

    ProviderNamespace : Microsoft.ResourceHealth
    RegistrationState : Registered
    ResourceTypes : {availabilityStatuses, operations}
    Locations : {}

    ProviderNamespace : Microsoft.Storage
    RegistrationState : Registered
    ResourceTypes : {storageAccounts, operations, storageAccounts/listAccountSas, usages...}
    Locations : {East US, East US 2, West US, West Europe...}

    ProviderNamespace : Microsoft.ADHybridHealthService
    RegistrationState : Registered
    ResourceTypes : {services, addsservices, configuration, operations...}
    Locations : {West US}

    ProviderNamespace : Microsoft.Authorization
    RegistrationState : Registered
    ResourceTypes : {roleAssignments, roleDefinitions, classicAdministrators, permissions...}
    Locations : {}

    ProviderNamespace : Microsoft.Features
    RegistrationState : Registered
    ResourceTypes : {features, providers, operations}
    Locations : {}

    ProviderNamespace : Microsoft.Resources
    RegistrationState : Registered
    ResourceTypes : {tenants, locations, providers, checkresourcename...}
    Locations : {Central US, East Asia, Southeast Asia, East US...}

    ProviderNamespace : microsoft.support
    RegistrationState : Registered
    ResourceTypes : {operations, supporttickets}
    Locations : {North Central US, South Central US, Central US, West Europe...}

    PS C:\Windows\system32>

    Looking forward to your help & support.

    Thanks,
    Gulab Pasaha

  14. Hamid says:

    For Virtual machines created by portal, there is functionality in azure portal to move VM from one subscription to another.

    https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-move-vm/

  15. Antonio says:

    This post is great, much easier compared to others, thanks a lot, you made me save a lot of time!

  16. I had problems with CloudBerry Explorer.. tried in two different computers in two different networks and couldn´t pass 39% on the transfer.. it was a 128 GB VHD file...

  17. In time, I just found the Microsoft Azure Store Explorer and in the firts try, 100% success!

Skip to main content