Featured image of post First steps with Azure: Creating an Azure Resource Group with Azure CLI

First steps with Azure: Creating an Azure Resource Group with Azure CLI

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.

Image 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.

Image 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 .

Image 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 .

Image 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.

Image 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.

Image 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.

Image

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! [

Image ](https://faun.to/bP1m5)

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 👇

Built with Hugo
Theme Stack designed by Jimmy