while moving all resources from Resource group from once subscription to another subscription, getting error message as below.

Ram Waghmare 10 Reputation points
2023-03-22T23:36:08.0066667+00:00

while moving all resources from Resource group from once subscription to another subscription, getting error message as below.

{"code":"ResourceMoveProviderValidationFailed","target":"Microsoft.Web/serverFarms","message":"{"Code":"BadRequest","Message":"Please select all the Microsoft.Web resources from 'rg_cdp_plc_dev' resource group for cross-subscription migration. Also, please ensure destination resource group 'Test-dev-rg' doesn't have any Microsoft.Web resources before move operation. Here is the list of resources you have to move together: cdpapp (Microsoft.Web/sites)\r\n cdpapp-demo (Microsoft.Web/sites)\r\n cdpapp-api (Microsoft.Web/sites)\r\n cdpapp-stg (Microsoft.Web/sites). This resource is located in resource group 'rg_cdp_plc_dev', but hosted in the resource group 'rg_cdp_plc_stg'. This may be a result of prior move operations

but all resources are in single RG.

Azure Resource Mover
Azure Resource Mover
An Azure service used for moving multiple resources between Azure regions.
200 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 13,160 Reputation points
    2023-03-23T08:34:21.2066667+00:00

    while moving all resources from Resource group from once subscription to another subscription, getting error message as below.

    {"code":"ResourceMoveProviderValidationFailed","target":"Microsoft.Web/serverFarms","message":"{"Code":"BadRequest","Message":"Please select all the Microsoft.Web resources from 'rg_cdp_plc_dev' resource group for cross-subscription migration. Also, please ensure destination resource group 'Test-dev-rg' doesn't have any Microsoft.Web resources before move operation. Here is the list of resources you have to move together: cdpapp (Microsoft.Web/sites)\r\n cdpapp-demo (Microsoft.Web/sites)\r\n cdpapp-api (Microsoft.Web/sites)\r\n cdpapp-stg (Microsoft.Web/sites). This resource is located in resource group 'rg_cdp_plc_dev', but hosted in the resource group 'rg_cdp_plc_stg'. This may be a result of prior move operations

    but all resources are in single RG.

    $sourceResourceGroupName = "rg_cdp_plc_dev"
    $targetResourceGroupName = "Test-dev-rg"
    $targetSubscriptionId = "<TargetSubscriptionId>"
    $resources = Get-AzResource -ResourceGroupName $sourceResourceGroupName | Where-Object { $_.ResourceType -eq 'Microsoft.Web/sites' -or $_.ResourceType -eq 'Microsoft.Web/serverFarms' }
    $resourceIds = $resources.ResourceId
    Move-AzResource -DestinationResourceGroupName $targetResourceGroupName -DestinationSubscriptionId $targetSubscriptionId -ResourceId $resourceIds
    
    

    For Azure CLI, use the az resource move command:

    
    target_rg="Test-dev-rg"
    target_subscription="<TargetSubscriptionId>"
    resource_ids=$(az resource list --resource-group $source_rg --query "[?contains(type, 'Microsoft.Web')].id" -o tsv)
    az resource move --destination-group $target_rg --destination-subscription-id $target_subscription --ids $resource_ids
    
    
    0 comments No comments