locked
Problem moving an App Service Plan to a different Resource Group RRS feed

  • Question

  • I have two Resource Groups, call them Group1 and Group2. Within Group1 I have:
    - a web app (with its deployment slot) that I moved from Group2
    - a SQL Server and a SQL Database
    - 3 storage account
    - a Cloud Service (classic)

    In Group2 I have just one App Service Plan which contains the web app that it is now in Group1.

    When I try to move the App Service Plan it says (I see this in Audit Log) "ResourceGroup contains resources and cannot be deleted without deleting the resource first." that doesn't make much sense to me.

    Here I read:

    When working with web apps, you cannot move only an App Service plan. To move web apps, your options are:

    • Move all of the resources from one resource group to a different resource group, if the destination resource group does not already have Microsoft.Web resources.
    • Move the web apps to a different resource group, but keep the App Service plan in the original resource group.

    That sounds like referring to my problem but I'm not sure. Why I can have both the App Service Plan and the Web App pin the same Resource Group if I create them but cannot if I move them?


    • Edited by pmonte Wednesday, November 25, 2015 8:16 AM typo
    Wednesday, November 25, 2015 8:16 AM

All replies

  • Hi,

    I was just facing this type of confusion earliy this week.

    The arcticle says that you can only move :

    - Web apps to another resource group

    - Move the App service + Web apps from an RG to another

    that means

    You cannot move an App service plan only, the move must include a Web app

    The solution: If you want to move the App Service Plan to Group 1, you have to :

    - Move back the Web app to Group2 (So you will have Group 2 containing App Service Plan + Web App)

    - Move the Web App + App Service Plan to Group 1 (Together)

    Here the Powershell to move both resources in one time

    $SourceRG = 'SourceRGName'
    $DestRG = 'DestinationRGName'
    
    $WebAppName = 'BBBBBBB'
    $AppServiceName = 'AAAAAAAAAA'
    
    
    $webapp = Get-AzureResource -ResourceGroupName $SourceRG -ResourceName $WebAppName -ResourceType Microsoft.Web/sites
    
    $plan = Get-AzureResource -ResourceGroupName $SPSourceRG -ResourceName $AppServiceName -ResourceType Microsoft.Web/serverFarms
    Move-AzureResource -DestinationResourceGroupName $DestRG -ResourceId ($plan.ResourceId, $webapp.ResourceId)

    If you encounter other issues, just ping me


    Regards, Samir Farhat || Datacenter Consultant || The way to share my knowledge with the community Visit my blog : buildwindows.wordpress.com buildwindows.wordpress.com </a>

    Wednesday, November 25, 2015 2:02 PM
  • I had the same idea soon after I posted this question, so I tried what you suggest but it didn't work and the error message is even more cryptic:

    ResourceGroup contains resources and cannot be deleted without deleting the resource first.

    I'd like to underline that I'm not trying to delete the resource group, just move all resources in it. Anyideas?

    Thursday, November 26, 2015 8:12 AM