Moving resources between subscriptions in Azure can sometimes be tricky, especially when dealing with resources that are actively running and in use, like app services. The error message you encountered indicates that there's a mismatch in the resource's current group and its hosting group due to prior move operations. To address the issue and successfully move your resource group containing two app services from Subscription A to a new resource group under Subscription B without affecting the running app, follow these steps:
- Understand the Error
The error indicates a mismatch between where the resource is located and where it is hosted. This usually happens when a previous move was not fully completed or some resources have dependencies that span across resource groups.
- Revert to Original Hosting Resource Group
Before moving the resources to a new subscription, revert the resources back to their original hosting resource group. This step ensures that the resources are correctly aligned.
- Prepare for the Move
- Check Dependencies: Ensure there are no dependencies or linked resources that might be causing the issue.
- Permissions: Ensure you have the necessary permissions in both subscriptions (Owner or Contributor role).
- Same Tenant: Verify both subscriptions are under the same Azure Active Directory tenant.
- Plan for Minimal Downtime: Schedule the move during off-peak hours to minimize impact and notify stakeholders about the planned maintenance.
- Perform the Move Using Azure Portal or PowerShell
Revert to Original Resource Group (if needed)
Navigate to the Resource Group in Azure Portal:
- Go to the Azure Portal.
- Navigate to the current resource group of the app services.
- Select the resources (app services). - Click on "Move" > "Move to another resource group". - Select the original hosting resource group and confirm the move.
Move Resources to New Subscription
Using Azure Portal
Navigate to the Resource Group in Subscription A:
- Go to the Azure Portal.
- Navigate to the resource group containing the app services in Subscription A.
- Select the resources you want to move (e.g., app services). - Click on "Move" > "Move to another subscription". - Select Subscription B and the target resource group in Subscription B. **Confirm the Move**: - Review the list of resources to be moved. - Confirm and initiate the move.
Using Azure PowerShell
Login and Set Context:
powershellCopy code
# Log in to Azure
Connect-AzAccount
# Set the context to Subscription A
Select-AzSubscription -SubscriptionId "Subscription_A_ID"
Move Resources:
powershellCopy code
# Move the resource to Subscription B
Move-AzResource -ResourceId "/subscriptions/{Subscription_A_ID}/resourceGroups/{OLD_RESOURCE_GROUP}/providers/Microsoft.Web/sites/{AppServiceName}" `
-DestinationSubscriptionId "Subscription_B_ID" `
-DestinationResourceGroupName "NEW_RESOURCE_GROUP"
- Validate and Test
DNS and Configuration:
- Ensure DNS settings, custom domains, and SSL certificates are correctly configured.
- Verify application settings, connection strings, and environment variables.
- Test the app thoroughly to ensure it’s running as expected. - Monitor for any issues or performance degradation.
- Troubleshooting Common Issues
- Resource Lock: Ensure there are no resource locks on the resources or resource groups involved in the move.
- Quota and Limits: Check if the destination subscription has sufficient quotas and limits to accommodate the moved resources.
- Service Dependencies: Some resources might have dependencies that cannot be moved simultaneously. Plan to recreate or relink these dependencies post-move.
Reference Links
By carefully following these steps, you should be able to move your resource group with minimal disruption to your running app services.
- Understand the Error
The error indicates a mismatch between where the resource is located and where it is hosted. This usually happens when a previous move was not fully completed or some resources have dependencies that span across resource groups.
- Revert to Original Hosting Resource Group
Before moving the resources to a new subscription, revert the resources back to their original hosting resource group. This step ensures that the resources are correctly aligned.
- Prepare for the Move
- Check Dependencies: Ensure there are no dependencies or linked resources that might be causing the issue.
- Permissions: Ensure you have the necessary permissions in both subscriptions (Owner or Contributor role).
- Same Tenant: Verify both subscriptions are under the same Azure Active Directory tenant.
- Plan for Minimal Downtime: Schedule the move during off-peak hours to minimize impact.
- Perform the Move Using Azure Portal or PowerShell
Revert to Original Resource Group (if needed)
Navigate to the Resource Group in Azure Portal:
- Go to the Azure Portal.
- Navigate to the current resource group of the app services.
- Select the resources (app services). - Click on "Move" > "Move to another resource group". - Select the original hosting resource group and confirm the move.
Move Resources to New Subscription
Using Azure Portal
Navigate to the Resource Group in Subscription A:
- Go to the Azure Portal.
- Navigate to the resource group containing the app services in Subscription A.
- Select the resources you want to move (e.g., app services). - Click on "Move" > "Move to another subscription". - Select Subscription B and the target resource group in Subscription B. **Confirm the Move**: - Review the list of resources to be moved. - Confirm and initiate the move.
Using Azure PowerShell
Login and Set Context:
powershellCopy code
# Log in to Azure
Connect-AzAccount
# Set the context to Subscription A
Select-AzSubscription -SubscriptionId "Subscription_A_ID"
Move Resources:
powershellCopy code
# Move the resource to Subscription B
Move-AzResource -ResourceId "/subscriptions/{Subscription_A_ID}/resourceGroups/{OLD_RESOURCE_GROUP}/providers/Microsoft.Web/sites/{AppServiceName}" `
-DestinationSubscriptionId "Subscription_B_ID" `
-DestinationResourceGroupName "NEW_RESOURCE_GROUP"
- Validate and Test
DNS and Configuration:
- Ensure DNS settings, custom domains, and SSL certificates are correctly configured.
- Verify application settings, connection strings, and environment variables.
- Test the app thoroughly to ensure it’s running as expected. - Monitor for any issues or performance degradation.
- Troubleshooting Common Issues
- Resource Lock: Ensure there are no resource locks on the resources or resource groups involved in the move.
- Quota and Limits: Check if the destination subscription has sufficient quotas and limits to accommodate the moved resources.
- Service Dependencies: Some resources might have dependencies that cannot be moved simultaneously. Plan to recreate or relink these dependencies post-move.
By carefully following these steps, you should be able to move your resource group with minimal disruption to your running app services.