Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 151e668

Browse files
authored
Merge pull request #185760 from tfitzmac/0121movevm
change format for vm moves
2 parents 5758501 + c333a55 commit 151e668

File tree

1 file changed

+97
-61
lines changed

1 file changed

+97
-61
lines changed

articles/azure-resource-manager/management/move-limitations/virtual-machines-move-limitations.md

Lines changed: 97 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Move Azure VMs to new subscription or resource group
33
description: Use Azure Resource Manager to move virtual machines to a new resource group or subscription.
44
ms.topic: conceptual
5-
ms.date: 12/13/2021
5+
ms.date: 01/21/2022
66
ms.custom: devx-track-azurepowershell, devx-track-azurecli
77
---
88

@@ -17,62 +17,88 @@ The following scenarios aren't yet supported:
1717
* Virtual Machine Scale Sets with Standard SKU Load Balancer or Standard SKU Public IP can't be moved.
1818
* Virtual machines in an existing virtual network can't be moved to a new subscription when you aren't moving all resources in the virtual network.
1919
* Virtual machines created from Marketplace resources with plans attached can't be moved across subscriptions. For a potential workaround, see [Virtual machines with Marketplace plans](#virtual-machines-with-marketplace-plans).
20-
* Low priority virtual machines and low priority virtual machine scale sets can't be moved across resource groups or subscriptions.
20+
* Low-priority virtual machines and low-priority virtual machine scale sets can't be moved across resource groups or subscriptions.
2121
* Virtual machines in an availability set can't be moved individually.
2222

2323
## Azure disk encryption
2424

2525
You can't move a virtual machine that is integrated with a key vault to implement [Azure Disk Encryption for Linux VMs](../../../virtual-machines/linux/disk-encryption-overview.md) or [Azure Disk Encryption for Windows VMs](../../../virtual-machines/windows/disk-encryption-overview.md). To move the VM, you must disable encryption.
2626

27+
# [Azure CLI](#tab/azure-cli)
28+
2729
```azurecli-interactive
2830
az vm encryption disable --resource-group demoRG --name myVm1 --volume-type all
2931
```
3032

33+
# [PowerShell](#tab/azure-powershell)
34+
3135
```azurepowershell-interactive
3236
Disable-AzVMDiskEncryption -ResourceGroupName demoRG -VMName myVm1 -VolumeType all
3337
```
3438

39+
---
40+
3541
## Virtual machines with Marketplace plans
3642

3743
Virtual machines created from Marketplace resources with plans attached can't be moved across subscriptions. To work around this limitation, you can de-provision the virtual machine in the current subscription, and deploy it again in the new subscription. The following steps help you recreate the virtual machine in the new subscription. However, they might not work for all scenarios. If the plan is no longer available in the Marketplace, these steps won't work.
3844

3945
1. Get information about the plan.
4046

41-
```azurepowershell
42-
$vm = get-AzVM -ResourceGroupName demoRG -Name myVm1
43-
$vm.Plan
44-
```
45-
46-
```azurecli
47-
az vm show --resource-group demoRG --name myVm1 --query plan
48-
```
47+
# [Azure CLI](#tab/azure-cli)
48+
49+
```azurecli
50+
az vm show --resource-group demoRG --name myVm1 --query plan
51+
```
52+
53+
# [PowerShell](#tab/azure-powershell)
54+
55+
```azurepowershell
56+
$vm = get-AzVM -ResourceGroupName demoRG -Name myVm1
57+
$vm.Plan
58+
```
59+
60+
---
4961
5062
1. Check that the offering still exists in the Marketplace.
5163
52-
```azurepowershell
53-
Get-AzVMImageSku -Location "Central US" -PublisherName "Fabrikam" -Offer "LinuxServer"
54-
```
64+
# [Azure CLI](#tab/azure-cli)
65+
66+
```azurecli
67+
az vm image list-skus --publisher Fabrikam --offer LinuxServer --location centralus
68+
```
5569
56-
```azurecli
57-
az vm image list-skus --publisher Fabrikam --offer LinuxServer --location centralus
58-
```
70+
# [PowerShell](#tab/azure-powershell)
71+
72+
```azurepowershell
73+
Get-AzVMImageSku -Location "Central US" -PublisherName "Fabrikam" -Offer "LinuxServer"
74+
```
75+
76+
---
5977
6078
1. Either clone the OS disk to the destination subscription, or move the original disk after deleting the virtual machine from source subscription.
6179
6280
1. In the destination subscription, accept the Marketplace terms for your plan. You can accept the terms by running the following PowerShell command:
6381
64-
```azurepowershell
65-
Get-AzMarketplaceTerms -Publisher {publisher} -Product {product/offer} -Name {name/SKU} | Set-AzMarketplaceTerms -Accept
66-
```
82+
# [Azure CLI](#tab/azure-cli)
83+
84+
```azurecli
85+
az vm image terms accept --publisher {publisher} --offer {product/offer} --plan {name/SKU}
86+
```
6787
68-
```azurecli
69-
az vm image terms accept --publisher {publisher} --offer {product/offer} --plan {name/SKU}
70-
```
88+
# [PowerShell](#tab/azure-powershell)
7189
72-
Or, you can create a new instance of a virtual machine with the plan through the portal. You can delete the virtual machine after accepting the terms in the new subscription.
90+
```azurepowershell
91+
Get-AzMarketplaceTerms -Publisher {publisher} -Product {product/offer} -Name {name/SKU} | Set-AzMarketplaceTerms -Accept
92+
```
93+
94+
---
95+
96+
Or, you can create a new instance of a virtual machine with the plan through the portal. You can delete the virtual machine after accepting the terms in the new subscription.
7397
7498
1. In the destination subscription, recreate the virtual machine from the cloned OS disk using PowerShell, CLI, or an Azure Resource Manager template. Include the marketplace plan that's attached to the disk. The information about the plan should match the plan you purchased in the new subscription. For more information, see [Create the VM](../../../virtual-machines/marketplace-images.md#create-the-vm).
7599
100+
For more information, see [Move a Marketplace Azure Virtual Machine to another subscription](../../../virtual-machines/azure-cli-change-subscription-marketplace.md).
101+
76102
## Virtual machines with Azure Backup
77103
78104
To move virtual machines configured with Azure Backup, you must delete the restore points collections (snapshots) from the vault. Restore points already copied to the vault can be retained and moved.
@@ -94,68 +120,78 @@ If [soft delete](../../../backup/soft-delete-virtual-machines.md) is enabled for
94120
3. Move the VM to the target resource group.
95121
4. Reconfigure the backup.
96122
97-
### PowerShell
123+
### Script
98124
99125
1. Find the location of your virtual machine.
100126
101127
1. Find a resource group with the naming pattern - `AzureBackupRG_<VM location>_1`. For example, the name might be `AzureBackupRG_westus2_1`.
102128
103129
1. If you're moving only one virtual machine, get the restore point collection for that virtual machine.
104130
105-
```azurepowershell-interactive
106-
$restorePointCollection = Get-AzResource -ResourceGroupName AzureBackupRG_<VM location>_1 -name AzureBackup_<VM name>* -ResourceType Microsoft.Compute/restorePointCollections
107-
```
131+
# [Azure CLI](#tab/azure-cli)
108132
109-
Delete this resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
133+
```azurecli-interactive
134+
RESTOREPOINTCOL=$(az resource list -g AzureBackupRG_<VM location>_1 --resource-type Microsoft.Compute/restorePointCollections --query "[?starts_with(name, 'AzureBackup_<VM name>')].id" --output tsv)
135+
```
110136
111-
```azurepowershell-interactive
112-
Remove-AzResource -ResourceId $restorePointCollection.ResourceId -Force
113-
```
137+
# [PowerShell](#tab/azure-powershell)
114138
115-
1. If you're moving all the virtual machines with back ups in this location, get the restore point collections for those virtual machines.
139+
```azurepowershell-interactive
140+
$restorePointCollection = Get-AzResource -ResourceGroupName AzureBackupRG_<VM location>_1 -name AzureBackup_<VM name>* -ResourceType Microsoft.Compute/restorePointCollections
141+
```
116142
117-
```azurepowershell-interactive
118-
$restorePointCollection = Get-AzResource -ResourceGroupName AzureBackupRG_<VM location>_1 -ResourceType Microsoft.Compute/restorePointCollections
119-
```
143+
---
120144
121-
Delete each resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
145+
Delete this resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
122146
123-
```azurepowershell-interactive
124-
foreach ($restorePoint in $restorePointCollection)
125-
{
126-
Remove-AzResource -ResourceId $restorePoint.ResourceId -Force
127-
}
128-
```
147+
# [Azure CLI](#tab/azure-cli)
129148
130-
### Azure CLI
149+
```azurecli-interactive
150+
az resource delete --ids $RESTOREPOINTCOL
151+
```
131152
132-
1. Find the location of your virtual machine.
153+
# [PowerShell](#tab/azure-powershell)
133154
134-
1. Find a resource group with the naming pattern - `AzureBackupRG_<VM location>_1`. For example, the name might be `AzureBackupRG_westus2_1`.
155+
```azurepowershell-interactive
156+
Remove-AzResource -ResourceId $restorePointCollection.ResourceId -Force
157+
```
135158
136-
1. If you're moving only one virtual machine, get the restore point collection for that virtual machine.
159+
---
137160
138-
```azurecli-interactive
139-
RESTOREPOINTCOL=$(az resource list -g AzureBackupRG_<VM location>_1 --resource-type Microsoft.Compute/restorePointCollections --query "[?starts_with(name, 'AzureBackup_<VM name>')].id" --output tsv)
140-
```
161+
1. If you're moving all the virtual machines with back ups in this location, get the restore point collections for those virtual machines.
141162
142-
Delete this resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
163+
# [Azure CLI](#tab/azure-cli)
143164
144-
```azurecli-interactive
145-
az resource delete --ids $RESTOREPOINTCOL
146-
```
165+
```azurecli-interactive
166+
RESTOREPOINTCOL=$(az resource list -g AzureBackupRG_<VM location>_1 --resource-type Microsoft.Compute/restorePointCollections)
167+
```
147168
148-
1. If you're moving all the virtual machines with back ups in this location, get the restore point collections for those virtual machines.
169+
# [PowerShell](#tab/azure-powershell)
170+
171+
```azurepowershell-interactive
172+
$restorePointCollection = Get-AzResource -ResourceGroupName AzureBackupRG_<VM location>_1 -ResourceType Microsoft.Compute/restorePointCollections
173+
```
174+
175+
---
176+
177+
Delete each resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
178+
179+
# [Azure CLI](#tab/azure-cli)
180+
181+
```azurecli-interactive
182+
az resource delete --ids $RESTOREPOINTCOL
183+
```
149184
150-
```azurecli-interactive
151-
RESTOREPOINTCOL=$(az resource list -g AzureBackupRG_<VM location>_1 --resource-type Microsoft.Compute/restorePointCollections)
152-
```
185+
# [PowerShell](#tab/azure-powershell)
153186
154-
Delete each resource. This operation deletes only the instant recovery points, not the backed-up data in the vault.
187+
```azurepowershell-interactive
188+
foreach ($restorePoint in $restorePointCollection)
189+
{
190+
Remove-AzResource -ResourceId $restorePoint.ResourceId -Force
191+
}
192+
```
155193
156-
```azurecli-interactive
157-
az resource delete --ids $RESTOREPOINTCOL
158-
```
194+
---
159195
160196
## Next steps
161197

0 commit comments

Comments
 (0)