0
0
Azurecloud~5 mins

Subscriptions and management groups in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Managing many Azure subscriptions can get confusing. Management groups help organize subscriptions so you can apply rules and policies to many subscriptions at once.
When you have multiple Azure subscriptions for different teams or projects and want to organize them.
When you want to apply the same security rules or policies to many subscriptions easily.
When you want to see billing or usage information grouped by departments or business units.
When you want to control who can manage subscriptions in a large organization.
When you want to simplify compliance by grouping subscriptions under common rules.
Commands
This command creates a new management group named 'example-mg' with a friendly display name. Management groups help organize subscriptions.
Terminal
az account management-group create --name example-mg --display-name "Example Management Group"
Expected OutputExpected
{ "id": "/providers/Microsoft.Management/managementGroups/example-mg", "name": "example-mg", "properties": { "displayName": "Example Management Group", "details": { "parent": null } }, "type": "Microsoft.Management/managementGroups" }
--name - Sets the unique ID for the management group.
--display-name - Sets the friendly name shown in the Azure portal.
This command adds an existing subscription to the management group 'example-mg' so it inherits policies and access controls.
Terminal
az account management-group subscription add --name example-mg --subscription 12345678-1234-1234-1234-123456789abc
Expected OutputExpected
No output (command runs silently)
--name - Specifies the management group to add the subscription to.
--subscription - Specifies the subscription ID to add.
This command shows details about the management group 'example-mg', including its subscriptions and hierarchy.
Terminal
az account management-group show --name example-mg
Expected OutputExpected
{ "id": "/providers/Microsoft.Management/managementGroups/example-mg", "name": "example-mg", "properties": { "displayName": "Example Management Group", "details": { "children": [ { "id": "/subscriptions/12345678-1234-1234-1234-123456789abc", "type": "Subscription" } ], "parent": null } }, "type": "Microsoft.Management/managementGroups" }
--name - Specifies the management group to show.
This command deletes the management group 'example-mg'. You must remove or move subscriptions before deleting.
Terminal
az account management-group delete --name example-mg
Expected OutputExpected
No output (command runs silently)
--name - Specifies the management group to delete.
Key Concept

If you remember nothing else from this pattern, remember: management groups let you organize and control many Azure subscriptions together easily.

Common Mistakes
Trying to delete a management group that still has subscriptions assigned.
Azure does not allow deleting management groups that contain subscriptions.
Remove or move all subscriptions out of the management group before deleting it.
Using subscription names instead of subscription IDs when adding to a management group.
The command requires the subscription ID, not the display name, so it will fail if names are used.
Always use the subscription's GUID ID when adding it to a management group.
Not having sufficient permissions to create or manage management groups.
You need specific Azure roles like 'Management Group Contributor' to manage groups; otherwise commands fail.
Ensure your Azure account has the required permissions before running management group commands.
Summary
Create a management group to organize subscriptions with 'az account management-group create'.
Add subscriptions to the group using 'az account management-group subscription add'.
View the group's details and subscriptions with 'az account management-group show'.
Delete a management group only after removing all subscriptions from it.