Hi Khalid Hajjouji
The error you're encountering during the move operation is related to a constraint on Microsoft.Web resources, specifically the fact that some of your resources (like Microsoft.Web/sites
and Microsoft.Web/serverFarms
) need to be moved together as a group.
You have resources like az-func-app-alz-test
, az-logic-app-alz-test
, and ASP-rgm365spazltest-ba8b
in the resource group, which are tied together. To resolve this, you need to ensure that all these resources are selected for the move operation and that they stay together when moved to the destination.
Could you please follow the below steps to resolve this issue:
- Identify All Required Microsoft.Web Resources. Use the below command to list all Microsoft.Web resources in the source group:
az resource list --resource-group sourceResourceGroupName --resource-type Microsoft.Web/sites --query "[].id" -o tsv
az resource list --resource-group sourceResourceGroupName --resource-type Microsoft.Web/serverFarms --query "[].id" -o tsv
- Check that
destinationResourceGroupName
doesn't already have Microsoft.Web resources:
az resource list --resource-group destinationResourceGroupName --query "[?type=='Microsoft.Web/sites' || type=='Microsoft.Web/serverFarms'].name" -o tsv
If it does, you must either remove them or choose a different empty destination group for this operation.
- Once you’ve gathered all the required resource IDs:
az resource move \
--destination-group destinationResourceGroupName \
--destination-subscription-id destinationSubscriptionGUID \
--ids <id1> <id2> <id3> ...
Alternatively, you can try the below command
# Log in to Azure using service principal
az login --service-principal --username 'someGUID' --password 'someSecret' --tenant 'tenantGuid'
# Set the source subscription
az account set --subscription 'sourceSubscriptionGUID'
# List all resource IDs in the source group, including Microsoft.Web resources
resource_ids=$(az resource list --resource-group 'sourceResourceGroupName' --query "[].id" -o tsv)
# Move resources to the destination group and subscription
az resource move \
--destination-group 'destinationResourceGroupName' \
--destination-subscription-id 'destinationSubscriptionGUID' \
--ids $resource_ids
Hope this helps!
Please Let me know if you have any queries.
If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.