First steps with Azure: Creating an Azure Resource Group with Azure CLI
An Azure Resource Group is a container that holds related resources for an Azure solution. This is an important resource in Azure and in this post, I will continue the series of Basic commands for Azure CLI and show how it is possible to create Azure Resource Groups using Azure CLI.
Photo by Simon Infanger on Unsplash
What is Az CLI?
Az CLI or Azure CLI is a command line interface with Azure. It can be used in any command line prompt, including PowerShell and Bash, and it allows the creation of resources and resource groups, executing actions, and much more possibilities. In the previous post, I showed the basic commands to connect and configure your Azure Subscription using Azure CLI, if you donât know how to configure your Azure CLI local environment you can check it here.
What is an Azure Resource Group
According to Microsoft documentation, this is the definition of an Azure Resource Group:
A resource group is a container that holds related resources for an Azure solution. The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. You decide how you want to allocate resources to resource groups based on what makes the most sense for your organization. Generally, add resources that share the same lifecycle to the same resource group so you can easily deploy, update, and delete them as a group.
In practice, we can consider it as a âDirectoryâ on Azure where you can group your resources. There are many ways to organize it, the most common is to make them small with resources of the same context.
For more information, you can check the official documentation here.
Az CLI commands for Azure Resource Group
Azure Resource Group - Summary of commands
Below there is a summary of all commands used in this tutorial. You can copy it and replace the values between <> to your own values :)
How to use Az CLIÂ Help?
It is also possible to check all commands related to resource groups with the command az --help . For more details about how to use the help check this post where I also show how to login into Azure Subscription with Azure CLI.
az group helpâââImage by author
How to list existing Azure Resource Groups with Az CLI
The command used to list Azure Resource Groups is az group list . It will return a JSON by default. To have a more human understandable output you can add --output tablein front of the command or any other output of your choice. The final command would beaz group list --output table .
az group listâââImage by author
How to create an Azure Resource Group with Az CLI
To create a new Azure Resource Group, it is necessary to provide two required information:
- Location: The Azure Region where your resource group will be created.
- **Name: **The name of your Resource Group
The final command is az group create --location <location of your resource group> --name <name of your resource group> . Replace the content between <> with your own values .
az group createâââImage by author
To check additional options use the command az group --help .
After creation, run again the command az group list --output tableto check if the resource group is shown.
az group listâââImage by author
How to show details of an Azure Resource Group with Az CLI
To check the details of a specific Resource Group, you can run the command az group show --name <your resource group name>Â . This command returns basically the same information after the creation command.
az group showâââImage by author
How to delete an Azure Resource Group with Az CLI
The delete command will prompt if you are sure about executing the delete operation. This is because all resources created under this resource group will also be deleted, so run this command only when you want to delete them as well.
After the conclusion of the command, after running the list command the created resource group is not listed anymore.

Conclusion
The Resource Groups are an important part of Azure and automating its creation is a fundamental part of a DevOps process.
See you in the next post! [
Join FAUN: Website** đ»|Podcast đïž|Twitter đŠ|Facebook đ„|Instagram đ·|Facebook Group đŁïž|Linkedin Group đŹ|** Slack đ±|Cloud Native News** đ°|More.**
If this post was helpful, please click the clap đ button below a few times to show your support for the author đ
](