Lesson 3 of 3 Azure Resource Hierarchy

Managing Resource Groups and Moving Resources

Resource groups hold related resources. This lesson explains how to design them around life cycles and what happens when resources move between them.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the rules that apply to resource groups and their locations.
  • Explain how to group resources by life cycle.
  • Describe the effects of moving resources between resource groups and subscriptions.

Resource group rules

Every resource belongs to exactly one resource group, and every resource group belongs to one subscription. Resource groups cannot be nested and cannot be renamed. A resource group has a location, which is where its metadata is stored and which matters for compliance, but it can contain resources in any region. If the resource group's region is unavailable, resources in other regions keep working, but the group's metadata cannot be updated until the region recovers.

The guiding principle is to group resources that share a life cycle: they are deployed, updated and deleted together. Deleting a resource group deletes every resource in it, which is convenient for test environments and dangerous for production; a CanNotDelete lock prevents it. Role assignments, policy assignments, locks, tags and budgets set on a resource group apply to everything inside.

The following diagram shows three resource groups organised by life cycle: a web tier, a database and a shared virtual network.

Organizing resource groups by life cycle. The web tier, redeployed weekly by deletion, gets its own group; the database sits in a separate group with a CanNotDelete lock; and the shared VNet lives in a networking group owned by the network team with Network Contributor. One group for all three would expose the database to the weekly deletion.
The group names are illustrative.
True or false

Resource group rules

Exam skills 1.3.4

Check the rules that every resource group follows.

Log in to try this activity Interactive activities are free with an account.

Moving resources

Resources can be moved to another resource group in the same subscription or to another subscription in the same tenant. The steps below describe a move in the portal.

  1. Check support

    Confirm that the resource type supports moving; some, such as certain classic or networking resources, do not, or have restrictions.

  2. Select dependencies

    Select dependent resources to move together, such as a VM with its disks, network interfaces and public IP.

  3. Validate

    The portal validates the move; Azure checks permissions, dependencies, registered providers and quotas in the target.

  4. Move

    During the move, the source and target resource groups are locked for create, update and delete operations, but the resources keep running.

  5. Update references

    Resource IDs change, so update scripts, templates, alerts and any role assignments made directly on the moved resources.

Moving needs Microsoft.Resources/subscriptions/resourceGroups/moveResources/action on the source group and write permission on the target group; Contributor on both is sufficient. Moving a resource does not change its region; changing region requires Azure Resource Mover or redeployment.

Put in order

Moving a VM to another resource group

Exam skills 1.3.4

Arrange the steps of a resource move in the portal.

Log in to try this activity Interactive activities are free with an account.
Worked example

Organizing by life cycle

A workload has a web tier, a database and a shared virtual network used by several other workloads. The web tier is redeployed weekly by deleting and recreating its resources. How should you organize the resource groups?

Place the web tier in its own resource group so that it can be deleted and redeployed as a unit. Keep the database in a separate group with a CanNotDelete lock, and place the shared VNet in a networking resource group owned by the network team with Network Contributor assigned there. Putting all three in one group would expose the database and the shared VNet to the weekly deletion and mix access requirements.

Check yourself

Does moving a resource to another resource group change its region?

Show answer

No. A move changes the resource group (and the resource ID), not the region; changing region needs Azure Resource Mover or redeployment.

Exam Tips

Remember for the exam

  • A resource group's location stores metadata; its resources can be in any region.
  • Deleting a resource group deletes all of its resources.
  • Moving resources changes their IDs but not their region.
  • Move dependent resources together and validate before moving.