Reputation: 172
I am attempting to move a resource group (that contains a VM with its dependant resources e.g. network interface etc) to a new subscription and resource group. (the move works fine if done via the GUI)
My Script:
foreach ($resource in $resources) {Move-AzureRmResource
-DestinationResourceGroupName "newresourcegroup" -ResourceId $resource.resourceID -DestinationSubscriptionId 123456}
Its failing with
Move-AzureRmResource : {"error":{"code":"ResourceMoveProviderValidationFailed","message":"Resource move validation failed. Please see details. Diagnostic information: timestamp
etc...
"The move resources request does not contain all the dependent resources. Please check error details for missing resource ids.\"}],\"code\":\"MissingMoveDependentResources\",\"message\":\"The move resources request does not contain all the dependent resources. Please check error details for missing resource ids.\"}}"},{"target":"Microsoft.Network/networkInterfaces","message":"{\"error\":{\"code\":\"MissingMoveDependentResources\",\"message\":\"The move resources request does not contain all the dependent resources. Please check details for missing resource Ids
Clearly I need to specify the dependant resources somehow, but there doesn't appear to be a parameter for "dependant resources" for the Move-AzureRmResource module.
a. How can I determine what the dependant resources are?
b. How do I specify them in the move cmdlet?
Upvotes: 0
Views: 7027
Reputation: 1
I would add that a move to a new subscription requires that dependent resources be moved at the same time. This requires first organizing resources in the same RG (at this time anyway) before the move operation can succeed. If you are merely moving resources between RGs, then you could do the move without a re-org in your RGs. Remember you may have VM extensions that are hidden objects that can fail, and things like Azure Backup that would need to be addressed before and after the move.
-DestinationSubscriptionId $AzureTargetSubscription.SubscriptionId
-ResourceId $Ids.ResourceID"Upvotes: 0
Reputation: 27793
The move resources request does not contain all the dependent resources
According to your scripts, it seems that you just traverse through resources and move them one by one to another resource group in new subscription. But as we know, some resource may have some dependent resources, to move this type of resource (such as virtual machine etc), we should make sure we also move all of the dependent resources, otherwise, the move operation will fail.
Before moving services, we need to know what services that enable move and limitations. Besides, please refer to Use Powershell to move a VM to know how to move resource that requires the dependent resources.
Upvotes: 1