Azure VM Migrate Limitation

Kaushalendra Kumar 106 Reputation points
2022-08-29T08:32:54.563+00:00

I am trying to migrate VM from one subscription to another subscription. For achieving successful migration I am doing the following steps-

1) Delete the VM and nic from the source subscription, leaving the OS Disk and Data Disk(s)
2) Move the OS Disk and Data Disk(s) from the source subscription to the destination subscription.
3) Use Azure CLI to create the VM in the destination subscription by attaching the OS and data disk(s).

When I use the above method, while creating the VM I get the following error -

 az vm create --subscription <subs> -n vm-kaushal-mig-test01   \  
--os-type Linux \  
--attach-os-disk vm-kaushal-mig-test02_OsDisk \  
--attach-data-disks vm-kaushal-mig-test02_DataDisk_0 vm-kaushal-mig-test02_DataDisk_1 \  
--size Standard_B2s \  
--subnet /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/virtualNetwork/vnet/subnets/default \  
--public-ip-address ""  

It is recommended to use parameter "--public-ip-sku Standard" to create new VM with Standard public IP. Please note that the default public IP used for VM creation will be changed from Basic to Standard in the future.

{  
    "status": "Failed",  
    "error": {  
        "code": "DeploymentFailed",  
        "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",  
        "details": [  
            {  
                "code": "BadRequest",  
                "message": "{\r\n  \"error\": {\r\n    \"code\": \"InvalidResourceReference\",\r\n    \"message\": \"Resource /subscriptions/XX/resourceGroups/XX/providers/Microsoft.Network/virtualNetworks/vnet/subnets/default referenced by resource /subscriptions/XX/resourceGroups/XX/providers/Microsoft.Network/networkInterfaces/vm-kaushal-mig-test01VMNic was not found. Please make sure that the referenced resource exists, and that both resources are in the same region.\",\r\n    \"details\": []\r\n  }\r\n}"  
            }  
        ]  
    }  
}  

Maybe someone can help with this error and tell me why I am getting this?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,306 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yannic Graber 586 Reputation points MVP
    2022-08-30T16:10:21.897+00:00

    Since your stated goal is just to your VM from one subscription to an other one, I suggest an other solution, rather than deleting the VM and NIC and reuse the disk.
    Is there any reason why you did not use the Azure resource mover capabilities straight away? I suggest to do so, as following.

    1. Double check, if all your used resources are supported to move. The one you mentioned, are supported. Anyway, doublecheck with this link.
    2. Make sure all your dependent resources (NIC, Network, Disk, etc.) are in the same Resource Group (RG).
    3. Go to the RG and select all the needed resources to move (checkbox).
    4. Select "Move"
    5. Select "Move to an other Subscription"

    236233-sub-move.png

    Also here you have the more detailed but more complex Microsoft Documentation (Docs).

    I hope my suggestion does help you with your tasks. If so, please accept as answer/solution. If not, please feel free to ask further questions.
    Best, Yannic

    1 person found this answer helpful.
    0 comments No comments

  2. Ryan Hill 26,316 Reputation points Microsoft Employee
    2022-08-30T01:34:10.14+00:00

    The reason you're getting the error is because the subnet you're attaching the VM to is looking for NIC vm-kaushal-mig-test01VMNic wasn't found. For some reason, the subnet sees the NIC as a referenced resource, in other words, there's a still network association between the NIC and the subnet. I'm not sure if default subnet is in the source or destination; but, since you're migrating resources from between subscriptions, either verify the association between the NIC and the vnet or create a new NIC.

    Since you elected to delete and create your VM resources, I've updated your tag so that right audience is viewing your question.

    0 comments No comments