This guide demonstrates how to create, list, and delete Azure Resource Groups using Azure CLI and Azure PowerShell, with annotated command examples.
- Azure CLI or Azure PowerShell installed.
- Logged in to Azure via
az loginorConnect-AzAccount.
# Create a new resource group named "test-resource-group" in the "northeurope" region
az group create -l northeurope -n test-resource-group📄 Example Output
{
"id": "/subscriptions/<sub-id>/resourceGroups/test-resource-group",
"location": "northeurope",
"name": "test-resource-group",
"properties": {
"provisioningState": "Succeeded"
},
"type": "Microsoft.Resources/resourceGroups"
}# List all resource groups in your subscription
az group list📄 Example Output (JSON)
[
{
"name": "DEMO-RG",
"location": "northeurope",
"properties": {
"provisioningState": "Succeeded"
}
},
...
]# Query and display only name and location in table format
az group list --query "[].{Name:name, Location:location}" --output table🖥️ Output:
Name Location
------------------- ------------
DEMO-RG northeurope
test-resource-group northeurope
NetworkWatcherRG koreacentral
# Delete the specified resource group
az group delete -n test-resource-group📌 Note: Prompts for confirmation — type y to proceed.
# Create a new resource group in northeurope
New-AzResourceGroup -Name test-resource-group -Location northeurope📄 Example Output
ResourceGroupName : test-resource-group
Location : northeurope
ProvisioningState : Succeeded
ResourceId : /subscriptions/<sub-id>/resourceGroups/test-resource-group
# Delete the specified resource group
Remove-AzResourceGroup -Name test-resource-group📌 Note: Prompts for confirmation — type Y to confirm.