Move a set of Azure resources from one subscription to another

BONIER Charline 0 Reputation points
2023-02-24T09:28:03.8066667+00:00

I have created a Powershell script that allows me to move resources in a DEV subscription to a resource group in a PROD subscription.

When I run the script: it runs and runs but does not stop so I stop the execution however when I look in Azure my resources have been moved.

Do you know how I can fix the problem ?

Here is the script

$resources = Get-AzResource -Name * -ResourceGroupName "Name"
Move-AzResource -DestinationResourceGroupName "Test" -DestinationSubscriptionId "ID" -ResourceId $resources.Id -Force

I looked in the Azure documentation but couldn't find anything : Link : https://learn.microsoft.com/en-us/powershell/module/az.resources/move-azresource?view=azps-9.4.0

Azure Resource Mover
Azure Resource Mover
An Azure service used for moving multiple resources between Azure regions.
200 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,032 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rohit Kumar Sinha 1,321 Reputation points
    2023-02-24T13:49:51.77+00:00

    HI ,

    You can use Azure Resource Mover , which is the native and seamless option to do this. Please refer to the below doc on how to configure this , which is fairly easy

    https://learn.microsoft.com/en-us/azure/resource-mover/about-move-process

    https://learn.microsoft.com/en-us/azure/resource-mover/move-region-within-resource-group

    0 comments No comments