You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/management/move-resource-group-and-subscription.md
+28-26Lines changed: 28 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ ai-usage: ai-assisted
13
13
14
14
This article explains how to move Azure resources between resource groups, whether they are within the same subscription or across different subscriptions. If the move involves different subscriptions, both subscriptions must be part of the same Microsoft Entra ID tenant. You can perform the move using tools like the [Azure portal](#use-the-portal), [Azure PowerShell](#use-azure-powershell), [Azure CLI](#use-azure-cli), the [REST API](#use-rest-api), or [Python](#use-python).
15
15
16
-
During the move operation, both the source and target resource groups are locked. This means you cannot create, delete, or update resources within these resource groups while the move is in progress. However, existing resources remain fully operational. For instance, if you move a virtual machine (VM) from one resource group to another, the VM can't be deleted, and its properties (such as VM size) can't be modified during the move. Despite this, the VM continues to operate normally, and services relying on it will not experience any additional downtime. The lock can last up to four hours, but most moves are completed much faster, and the lock is removed accordingly.
16
+
During the move operation, both the source and target resource groups are locked. This means you can't create, delete, or update resources within these resource groups while the move is in progress. However, existing resources remain fully operational. For instance, if you move a virtual machine (VM) from one resource group to another, the VM can't be deleted, and its properties (such as VM size) can't be modified during the move. Despite this, the VM continues to operate normally, and services relying on it will not experience any additional downtime. The lock can last up to four hours, but most moves are completed faster, and the lock is removed accordingly.
17
17
18
-
Only top-level (parent) resources should be specified in the move request. Child resources are automatically moved along with their parent but cannot be moved independently. For example, a parent resource like `Microsoft.Compute/virtualMachines` can be moved, and its child resource, such as `Microsoft.Compute/virtualMachines/extensions`, will be moved with it. However, the child resource cannot be moved on its own.
18
+
Only top-level (parent) resources should be specified in the move request. Child resources are automatically moved along with their parent but can't be moved independently. For example, a parent resource like `Microsoft.Compute/virtualMachines` can be moved, and its child resource, such as `Microsoft.Compute/virtualMachines/extensions`, will be moved with it. However, the child resource can't be moved on its own.
19
19
20
-
While moving a resource preserves its dependencies with child resources, dependencies with other resources may break and require reconfiguration. Note that moving a resource only changes its associated resource group, it does not alter the physical region of the resource.
20
+
While moving a resource preserves its dependencies with child resources, dependencies with other resources may break and require reconfiguration. Moving a resource only changes its associated resource group, it doesn't alter the physical region of the resource.
21
21
22
22
> [!NOTE]
23
23
> Azure resources can't be moved if a read-only lock exists on the source or destination resource group or subscription.
@@ -128,7 +128,9 @@ For illustration purposes, we have only one dependent resource.
128
128
* Step 2: Move the resource and dependent resources together from the source subscription to the target subscription.
129
129
* Step 3: Optionally, redistribute the dependent resources to different resource groups within the target subscription.
130
130
131
-
## Use the portal
131
+
## Move resources
132
+
133
+
### Use the portal
132
134
133
135
To move resources, select the resource group that contains those resources.
134
136
@@ -166,9 +168,9 @@ When the move has completed, you're notified of the result.
166
168
167
169
:::image type="content" source="./media/move-resource-group-and-subscription/view-notification.png" alt-text="Screenshot of the Azure portal displaying a notification with the results of the move operation.":::
168
170
169
-
## Use Azure PowerShell
171
+
###Use Azure PowerShell
170
172
171
-
### Validate
173
+
####Validate
172
174
173
175
To test your move scenario without actually moving the resources, use the [Invoke-AzResourceAction](/powershell/module/az.resources/invoke-azresourceaction) command. Use this command only when you need to predetermine the results.
174
176
@@ -194,7 +196,7 @@ If validation passes, you see no output.
194
196
195
197
If validation fails, you see an error message describing why the resources can't be moved.
196
198
197
-
### Move
199
+
####Move
198
200
199
201
To move existing resources to another resource group or subscription, use the [Move-AzResource](/powershell/module/az.resources/move-azresource) command. The following example shows how to move several resources to a new resource group.
To move to a new subscription, include a value for the `DestinationSubscriptionId` parameter.
212
214
213
-
## Use Azure CLI
215
+
###Use Azure CLI
214
216
215
-
### Validate
217
+
####Validate
216
218
217
219
To test your move scenario without actually moving the resources, use the [az resource invoke-action](/cli/azure/resource#az-resource-invoke-action) command. Use this command only when you need to predetermine the results. To run this operation, you need the:
218
220
@@ -236,7 +238,7 @@ If validation passes, you see:
236
238
237
239
If validation fails, you see an error message describing why the resources can't be moved.
238
240
239
-
### Move
241
+
####Move
240
242
241
243
To move existing resources to another resource group or subscription, use the [az resource move](/cli/azure/resource#az-resource-move) command. In the `--ids` parameter, provide a space-separated list of the resource IDs to move.
To move to a new subscription, provide the `--destination-subscription-id` parameter.
260
262
261
-
## Use Python
263
+
###Use Python
262
264
263
-
### Validate
265
+
####Validate
264
266
265
267
To test your move scenario without actually moving the resources, use the [ResourceManagementClient.resources.begin_validate_move_resources](/python/api/azure-mgmt-resource/azure.mgmt.resource.resources.v2022_09_01.operations.resourcesoperations#azure-mgmt-resource-resources-v2022-09-01-operations-resourcesoperations-begin-validate-move-resources) method. Use this method only when you need to predetermine the results.
266
268
@@ -302,7 +304,7 @@ If validation passes, you see no output.
302
304
303
305
If validation fails, you see an error message describing why the resources can't be moved.
304
306
305
-
### Move
307
+
####Move
306
308
307
309
To move existing resources to another resource group or subscription, use the [ResourceManagementClient.resources.begin_move_resources](/python/api/azure-mgmt-resource/azure.mgmt.resource.resources.v2022_09_01.operations.resourcesoperations#azure-mgmt-resource-resources-v2022-09-01-operations-resourcesoperations-begin-move-resources) method. The following example shows how to move several resources to a new resource group.
The [validate move operation](/rest/api/resources/resources/validate-move-resources) lets you test your move scenario without actually moving the resources. Use this operation to check if the move succeeds. Validation is automatically called when you send a move request. Use this operation only when you need to predetermine the results. To run this operation, you need the:
346
348
@@ -393,7 +395,7 @@ While the operation is still running, you continue to receive the 202 status cod
To move existing resources to another resource group or subscription, use the [Move resources](/rest/api/resources/resources/moveresources) operation.
399
401
@@ -412,19 +414,19 @@ In the request body, you specify the target resource group and the resources to
412
414
413
415
## Frequently asked questions
414
416
415
-
### My resource move operation, which usually takes a few minutes, has been running for almost an hour. Is there something wrong?
417
+
**My resource move operation, which usually takes a few minutes, has been running for almost an hour. Is there something wrong?**
416
418
417
419
Moving a resource is a complex operation that has different phases. It can involve more than just the resource provider of the resource you're trying to move. Because of the dependencies between resource providers, Azure Resource Manager allows 4 hours for the operation to complete. This time period gives resource providers a chance to recover from transient issues. If your move request is within the four-hour period, the operation keeps trying to complete and may still succeed. The source and destination resource groups are locked during this time to avoid consistency issues.
418
420
419
-
### Why is my resource group locked for four hours during resource move?
421
+
**Why is my resource group locked for four hours during resource move?**
420
422
421
423
A move request is allowed a maximum of four hours to complete. To prevent modifications on the resources being moved, both the source and destination resource groups are locked during the resource move.
422
424
423
425
There are two phases in a move request. In the first phase, the resource is moved. In the second phase, notifications are sent to other resource providers that are dependent on the resource being moved. A resource group can be locked for the entire four hours when a resource provider fails either phase. During the allowed time, Resource Manager retries the failed step.
424
426
425
427
If a resource can't be moved within four hours, Resource Manager unlocks both resource groups. Resources that were successfully moved are in the destination resource group. Resources that failed to move are left the source resource group.
426
428
427
-
### What are the implications of the source and destination resource groups being locked during the resource move?
429
+
**What are the implications of the source and destination resource groups being locked during the resource move?**
428
430
429
431
The lock prevents you from deleting either resource group. Secondly, within each resource group, the lock prevents you from creating a new resource, deleting a resource, or updating a resource’s properties (for example, changing the size of a VM).
430
432
@@ -436,9 +438,9 @@ In the image below, the VM resource belongs to a resource group ("TestB") that i
436
438
437
439
:::image type="content" source="./media/move-resource-group-and-subscription/move-error-delete-2.png" alt-text="Screenshot of the Azure portal showing an error message when a user tries to update a property (VM size) of the VM.":::
438
440
439
-
Additionally, during a resource move, neither the source nor the destination resource group can participate in other move operations simultaneously. For example, if resources are being moved from Resource Group A to Resource Group B, neither Group A nor Group B can be involved in another move operation, such as moving resources to or from Resource Group C, at the same time. This restriction ensures that resource groups are not locked by multiple conflicting operations during the move process.
441
+
Additionally, during a resource move, neither the source nor the destination resource group can participate in other move operations simultaneously. For example, if resources are being moved from Resource Group A to Resource Group B, neither Group A nor Group B can be involved in another move operation, such as moving resources to or from Resource Group C, at the same time. This restriction ensures that resource groups aren't locked by multiple conflicting operations during the move process.
440
442
441
-
### What does the error code "MissingMoveDependentResources" mean?
443
+
**What does the error code "MissingMoveDependentResources" mean?**
442
444
443
445
When you move a resource, its dependent resources must either exist in the destination resource group or subscription, or be included in the move request. You get the MissingMoveDependentResources error code when a dependent resource doesn't meet this requirement. The error message has details about the dependent resource that needs to be included in the move request.
444
446
@@ -459,29 +461,29 @@ For example, moving a virtual machine could require moving seven resource types
459
461
Another common example involves moving a virtual network. You may have to move several other resources associated with that virtual network. The move request could require moving public IP addresses, route tables, virtual network gateways, network security groups, and others.
460
462
In general, a virtual network gateway must always be in the same resource group as its virtual network, they can't be moved separately.
461
463
462
-
### What does the error code "RequestDisallowedByPolicy" mean?
464
+
**What does the error code "RequestDisallowedByPolicy" mean?**
463
465
464
466
Resource Manager validates your move request before attempting the move. This validation includes checking policies defined on the resources involved in the move. For example, if you're attempting to move a key vault but your organization has a policy to deny the creation of a key vault in the target resource group, validation fails and the move is blocked. The returned error code is **RequestDisallowedByPolicy**.
465
467
466
468
For more information about policies, see [What is Azure Policy?](../../governance/policy/overview.md).
467
469
468
-
### Why can't I move some resources in Azure?
470
+
**Why can't I move some resources in Azure?**
469
471
470
472
Currently, not all resources in Azure support move. For a list of resources that support move, see [Move operation support for resources](move-support-resources.md).
471
473
472
-
### How many resources can I move in a single operation?
474
+
**How many resources can I move in a single operation?**
473
475
474
476
When possible, break large moves into separate move operations. Resource Manager immediately returns an error when there are more than 800 resources in a single operation. However, moving less than 800 resources may also fail by timing out.
475
477
476
-
### What is the meaning of the error that a resource isn't in succeeded state?
478
+
**What is the meaning of the error that a resource isn't in succeeded state?**
477
479
478
480
When you get an error message that indicates a resource can't be moved because it isn't in a succeeded state, it may actually be a dependent resource that is blocking the move. Typically, the error code is **MoveCannotProceedWithResourcesNotInSucceededState**.
479
481
480
482
If the source or target resource group contains a virtual network, the states of all dependent resources for the virtual network are checked during the move. The check includes those resources directly and indirectly dependent on the virtual network. If any of those resources are in a failed state, the move is blocked. For example, if a virtual machine that uses the virtual network has failed, the move is blocked. The move is blocked even when the virtual machine isn't one of the resources being moved and isn't in one of the resource groups for the move.
481
483
482
484
When you receive this error, you have two options. Either move your resources to a resource group that doesn't have a virtual network, or [contact support](/azure/azure-portal/supportability/how-to-create-azure-support-request).
483
485
484
-
### Can I move a resource group to a different subscription?
486
+
**Can I move a resource group to a different subscription?**
485
487
486
488
No, you can't move a resource group to a new subscription. But, you can move all of the resources in the resource group to a resource group in another subscription. Settings such as tags, role assignments, and policies aren't automatically transferred from the original resource group to the destination resource group. You need to reapply these settings to the new resource group. For more information, see [Move resources to new resource group or subscription](./move-support-resources.md).
0 commit comments