Moving resources
Now, let's assume you have a resource in one resource group and want to move it to another one. There are a few possible scenarios when you would do so:
- If you simply made a mistake and provisioned a resource in an invalid resource group
- If you found resources that have a different life cycle and want to differentiate between deployments
- If you are redesigning an application and want to separate resources related to different domains
- If you do not want to perform a redeployment to place resources in a different resource group
In Azure, this operation is really simple – all you need to do is gather the following parameters:
- Destination group: A place where resources should be moved to
- IDs of resources: The identifiers of the resources you want to move
For example, I want to move an Azure Logic App named azureadministrator-euw-logicapp to a resource group named azureadministratornew-euw-rg.
The following is the full command I used to perform this operation:
$ az resource move --destination-group "azureadministratornew-euw-rg" --ids "/subscriptions/.../resourceGroups/azureadministrator-euw-rg/providers/Microsoft.Logic/workflows/azureadministrator-euw-logicapp"
The preceding command moves a specific resource (identified by its identifier) to a destination group inside the same subscription. Note that while moving the resource, a notification will appear in Azure portal stating that an operation is ongoing and that a certain resource may be moved in a moment, as shown in the following screenshot:
When the operation is completed, all the resources that were moved will have new IDs attached to them. The move operation does not break anything from a service point of view. However, you will have to remember to update your CI/CD pipelines if they deploy anything to Azure – in most cases, you are providing a resource group name, which will have to be updated in that case.
Before we sum up managing resource groups, there is one more concept worth mentioning. Each individual Azure service is managed by its API, called a resource provider. Each individual instance of a service is represented by a unique identifier called a resource ID. To understand how to build such an identifier, we must see what a resource provider identifier looks like.