Understanding Azure Resources and Resource Groups
This lesson explains what Azure resources are, how resource groups organize them, the rules that govern resource groups, and how to design them.
Learning outcomes
After completing this lesson, you will be able to:
- Describe Azure resources and resource IDs.
- Describe the rules that apply to resource groups.
- Explain how to group resources by lifecycle and access.
Resources
A resource is any manageable item that you create in Azure: a virtual machine, a virtual network, a storage account, a database, a web app, a public IP address and so on. Each resource has a type, a name, a location (region, for regional resources), and a unique resource ID that includes its subscription and resource group, such as /subscriptions/<id>/resourceGroups/rg-web/providers/Microsoft.Compute/virtualMachines/vm1. Resources are created and managed through Azure Resource Manager by any tool.
Resource groups and their rules
A resource group is a logical container that groups resources so that they can be managed as a unit. The following rules define how resource groups behave.
- Every resource must be in exactly one resource group; it cannot be in none or in two.
- Resource groups cannot be nested: a resource group cannot contain another resource group.
- Resources can be moved from one resource group to another, and most can be moved between subscriptions.
- A resource group has its own region, where its metadata is stored, but its resources can be in other regions.
- Deleting a resource group deletes every resource in it.
Because actions on a resource group apply to its contents, the resource group is a useful scope for management. A role assignment at a resource group gives access to all its resources; a policy, lock or budget at a resource group applies to them all; and costs can be analysed per resource group.
Resource group rules
Designing resource groups
There is no single correct way to organize resource groups, but the usual principle is to group resources that share a lifecycle: they are deployed, updated and deleted together. Common designs include:
- One resource group per application environment, such as
rg-shop-devandrg-shop-prod, so that the development environment can be removed in one action. - Separate resource groups for shared infrastructure, such as networking, that many applications use and that has a different lifecycle and owners.
- Resource groups aligned to access requirements, so that a team can be given Contributor on its own resource group without access to others.
A temporary environment, such as a training lab or proof of concept, is often created in its own resource group so that everything can be cleaned up by deleting the group, as the labs on this site do.
Designing resource groups
Deleting and organizing
A developer created a test environment containing two VMs, a virtual network and a storage account in a resource group named rg-test. The test is complete, and the developer wants to remove every resource with the fewest steps. A colleague suggests nesting rg-test inside a resource group named rg-projects to keep things tidy. What should the developer do?
Deleting rg-test deletes every resource in it in one operation, which is the fewest steps. The colleague's suggestion is not possible because resource groups cannot be nested; to organize several resource groups, the developer could use tags, place them in a dedicated subscription, or use naming conventions.
Can the resources in a resource group be in different regions from the resource group itself?
Show answer
Yes. The resource group's region stores only its metadata.
Exam Tips
Remember for the exam
- Each resource belongs to exactly one resource group; resource groups cannot be nested.
- Deleting a resource group deletes all of its resources.
- Resources in a group can be in different regions and can be moved between groups.
- Group resources that share a lifecycle and access requirements.