Move Resource Group to new Resource Group under different Subscription

Violet Zeng 10 Reputation points
2024-06-03T00:10:46.3966667+00:00

Hi,

I want to move my resource group (containing two app services) under Subscription A to new resource group under Subscription B. When I selected move resource, it shows the below error:

This resource is located in resource group 'NEW_RESOURCE_GROUP', but hosted in the resource group 'OLD_RESOURCE_GROUP'. This may be a result of prior move operations. Move it back to respective hosting resource group. Please check http://go.microsoft.com/fwlink/?LinkId=826382 for more information. (Code: BadRequest, Target: Microsoft.Web/serverFarms) (Code: ResourceMoveProviderValidationFailed)

How should I make the transfer without affecting the app? since the app is continuously running publicly.

Azure Resource Mover
Azure Resource Mover
An Azure service used for moving multiple resources between Azure regions.
224 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. William 620 Reputation points
    2024-06-03T01:14:26.5133333+00:00

    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:

    1. 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.

    1. 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.

    1. 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.
    1. 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.
      Move Resources Back to Original Group:
      - 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.
      Initiate the Move:
      - 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"
    
    1. 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.
      Testing:
      - Test the app thoroughly to ensure it’s running as expected.
      
         - Monitor for any issues or performance degradation.
      
    1. 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.

    1. 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.

    1. 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.

    1. 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.
    1. 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.
      Move Resources Back to Original Group:
      - 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.
      Initiate the Move:
      - 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"
    
    1. 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.
      Testing:
      - Test the app thoroughly to ensure it’s running as expected.
      
         - Monitor for any issues or performance degradation.
      
    1. 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.

    0 comments No comments