Part 1 - All About Azure Resource group, Web API & App Service Plan : Introduction


Recently, I was working on a Migration project which was related to a Web App migration from one azure subscription to another. The job was to migrate a web app, database, App service plan & storage from one Azure subscription to another.

So, let me explain what these terminology in Azure are :-

Web Apps - This is a kind of container were web applications/Websites can be published in azure.

(Please check this article to know how to publish a website on Azure)

When an web app is created in azure it asks for 2 entity :-

1. Resource Group.
2. App service plan.

Resource group - It's a container were you can have all resources which are tied to an application at one place. Suppose, you have a website which is using a database & a storage account. When you host the website in azure you will have to create a web app & a resource group. The best practices says to put the Web app, database & the storage account in the same resource group because they are required by the same application & by this way it will also be easy to migrated the resource group/Web app in future.

App Service Plan - An app service plan define the :-

1. Region (East US, West US etc)
2. Scale count (one, two, three instances etc)
3. Instance Size (Small, Medium, Large)
4. SKU (Free, shared, basic, standard, premium)

Now, coming back to my scenario - The Web app which we have to migrate was linked to some database & web api's all of this was created in different resource group. We first thought of migrating the database, web api to a single resource group & then do the subscription migration.

When we tried to migrate these resources individually to a single resource group, we got error message like :-

Error 1

Error Type

Resource move validation failed. Please see details. Diagnostic information: timestamp 'yyyymmddTxxxxxxx', subscription id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', tracking id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', request correlation id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'. (Code: ResourceMoveProviderValidationFailed)

Error Details

Cannot move resources because some serverfarm(s) are hosted by other resource group(s) but located in resource group 'Resource Group Name'. The list of serverfarms and corresponding hosting resource groups: '<App Service Plan : Resource Group>'. This may be a result of prior move operations. Move the serverfarm(s) back to respective hosting resource groups and try again. (Code: BadRequest, Target:Microsoft.Web/serverFarms)

Error 2

Error Type

Resource move validation failed. Please see details. Diagnostic information: timestamp 'yyyymmddTxxxxxxx', subscription id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', tracking id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', request correlation id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'. (Code: ResourceMoveProviderValidationFailed)

Error Details

Cannot move resources because some site(s) are hosted by other resource group(s) but located in resource group 'Resource Group Name'. The list of sites and corresponding hosting resource groups: '<Current Resource Group : Destination Resource Group>'. This may be a result of prior move operations. Move the site(s) back to respective hosting resource groups and try again. (Code: BadRequest, Target:Microsoft.Web/sites)


Error 3

Below is the error description copied right from Azure portal -

{"code":"ResourceMoveProviderValidationFailed","message":"Resource move validation failed. Please see details. Diagnostic information: timestamp 'xxxxxx', subscription id 'xxxx', tracking id 'xxxxx', request correlation id 'xxxxxx'.","details":[{"target":"Microsoft.Web/sites","message":"{\"Code\":\"BadRequest\",\"Message\":\"Cannot move resources because some site(s) are hosted by other resource group(s) but located in resource group 'Resource Group Name'. The list of sites and corresponding hosting resource groups: 'Current Resource Group : Destination Resource Group'. This may be a result of prior move operations. Move the site(s) back to respective hosting resource groups and try again.\",\"Target\":null,

\"Details\":[{\"Message\":\"Cannot move resources because some site(s) are hosted by other resource group(s) but located in resource group 'Destination Resource Group'. The list of sites and corresponding hosting resource groups: 'Source Resource Group:Destination resource Group'. This may be a result of prior move operations. Move the site(s) back to respective hosting resource groups and try again.\"},{\"Code\":\"BadRequest\"},{\"ErrorEntity\":{\"ExtendedCode\":\"52016\",\"MessageTemplate\":\"Cannot move resources because some site(s) are hosted by other resource group(s) but located in resource group '{1}'. The list of sites and corresponding hosting resource groups: '{0}'. This may be a result of prior move operations. Move the site(s) back to respective hosting resource groups and try again.\",\"Parameters\":[\"Source Resource Group:Destination resource Group\",\"Resource Group\"],\"Code\":\"BadRequest\",\"Message\":\"Cannot move resources because some site(s) are hosted by other resource group(s) but located in resource group 'Resource Group'. The list of sites and corresponding hosting resource groups: 'Source Resource Group:Destination resource Group'. This may be a result of prior move operations. Move the site(s) back to respective hosting resource groups and try again.\"}}],\"Innererror\":null}"}]}

As, I mentioned earlier the App which we were trying to migrate were having resources like Web api & database which were all hosted in different resource groups. When we tried to move them separately into a single resource group we got the above mentioned error message.

The idea was to move all the associated apps resources to a single resource group & then try migrating the entire resource group from the current azure subscription to another. 

Few interesting points which solved the above mentioned errors :-

1. Any resource can be moved to a new resource group anytime. There is no dependency for this.

2. The Database can be moved to any resource group anytime.

3. Web Apps are dependent on the App service plan & resource group.

4. App service plan of an web app can't be changed. It can only be changed if the new app service plan exist in the same resource group, has same location & same subscription.

5. Before creating a web app or at the time of creating an web app, Plan and create the App Service plan & resource group.

6. A web app can't be moved to a new resource group if the group is already having a app service plan or an web app which is using an app service plan created in the same group.


So, to solve the entire problem & to migrate the application successfully we had to migrate all the web apps to a single App service plan & resource group. We even had to recreate few web apps to do the migration successfully.

In the next part of the series we will see how we can migrate a Web App or Database to another resource group & how we can move a resource group to a new subscription.

Next Article :-

Part 2 - All About Azure Resource group, Web API & App Service Plan : Creating a web app in azure

No comments:

Post a Comment