ARM, Resource Groups and moving a resource between resource groups


I. Background

Recently I needed to order some of my Azure resources that were created long time ago.

At the time when I created these Azure resource, Resource Groups were not so popular and that widely used so my resources ended in the default resource groups for particular region. However, today we have new very powerful model for dealing with resource in Azure and today we will talk about it.

II. Azure Resource Manager

Now Azure Resource Manager ,in short ARM, is the main model for managing resource in Azure.

Here you can find more about ARM.

III. Resource Groups

However, the success of ARM is based on Resource Groups. Please check here for more information about Resource Groups.

There are several great reasons to use Resource Groups:

  1. The whole new Azure preview portal in built around ARM. It is so easy to view all resources in a single Resource Group with just 2 clicks – select Resource group menu item, filter until you locate your resource group and you are done.
  2. Resource Group is container for all resources related to a solution or one of its regional deployments
  3. You have advanced Role-based access control (RBAC) so you can easily manage it on Resource Group level
  4. ARM is amazing tool and in order to use it effectively , you should use Resource Groups
  5. You can leverage existing ARM templates or build your own for deploying simple and complex system with all their dependencies, with optimized deployment strategy provided by ARM. More information about ARM templates can be found here.

IV. Azure Resource Explorer

One of my favorite Azure tools is Azure Resource Explorer. This is a web site with URL – And it gives you a friendly UI for exploring all your resources grouped in Resource Groups. It is really handy because it exposes data usually hidden or not so easy to be spotted in the preview web portal.

For me it was very handy when I was looking for the exact IP of an Web App. In that case the Azure Resource Explorer was very useful. Later I found the same information in the web portal but Azure Resource Explorer provides friendly JSON format with all the information you would like to know about Azure resource.

Definitely check it and add it to your Azure toolbox!

IV. Moving a resource from one Resource Group to another

Back to my use case. I had several old resource – Azure Web Apps, that were created without specifying explicitly Resource Group so they ended up in one of the default groups for the region – “Default-Web-JapanEast”.

However, I was adding more resource to the service that was using the web app so I wanted to group them in a resource group.

This was easy for the new resource – a cloud service and storage account because I specified the group in the creation process.

However, it was not that easy to move web app to the same Resource Group.

First, there is not UI in the portal that help us to that.

So the only option is PowerShell script.

So first I tried the approach below – we just specify resource name and the new Resource Group we would like to movie it.

Get-AzureResource -ResourceName 'my-api-dev-japaneast' | Move-AzureResource -DestinationResourceGroupName 'myservice-dev-japaneast'

This did not work. I got an error specifying that all of the resources from the current group should be moved as well. So this will be useful approach if you are moving all resources from one to another Resource Group.

Then with the help of Azure Resource Explorer, I found the id of the resource and I tried the code below. If the name of my Azure Web App is “my-api-dev-japaneast” and you want to move it to “myservice-dev-japaneast” Resource Group the code will look like this. (Please input your subscription id)

Get-AzureResource -ResourceId /subscriptions/{subscription_id}/resourceGroups/Default-Web-JapanEast/providers/Microsoft.Web/sites/my-api-dev-japaneast | Move-AzureResource -DestinationResourceGroupName myservice-dev-japaneast

This worked and I was able to move my resource to the desired Resource Group.

I hope this will be helpful for you as well.

Thank you for your time and have a great weekend and very successful week!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s