Azure Resource Manager: Create Azure Resource Groups with xPlat

You can use the xPlat CLI tool from multiple guest operating systems to manage your Azure Resource Groups in the Resource Manager.

In my last article, we took a look at the Microsoft Azure Cross-Platform (xPlat) CLI Tool, some of its essential functions, how to install it, and how to authenticate to Microsoft Azure. We also looked at how to query for a list of Azure subscriptions, change our current subscription context, and switch between Azure’s REST APIs.

It’s time to learn a little bit more about the Azure Resource Manager (ARM) REST API architecture, in order to effectively perform automation tasks against your Microsoft Azure subscription. Cloud Academy offers a course specifically targeted at understanding the ARM REST API,  the course is called Introduction to Azure Resource Manager.

Introduction to Azure Resource Manager

xPlat: Managing ARM Azure Resource Groups

Once you’ve got an Azure subscription, the first step to provisioning cloud resources, of all types, is to create a container called a Resource Group. Although Azure Resource Manager is a multi-master, global service, Resource Groups are associated with one of the Azure “regions” (also called “locations”). You can get a list of Azure locations by using the “azure location list” command. Once you’ve selected an Azure region to create your Resource Group in, use the azure group create command to create it:

azure group create --name CloudAcademy --location westus

After calling this command, you will have created a new, empty Azure Resource Group.

After creating a Resource Group, you can deploy resources into it using declarative or imperative provisioning. You can also provision resources declaratively at the time you create the Resource Group. However for the purposes of learning, it’s easier to learn the individual components of the process. Once you understand the core concepts of ARM, you can use short cuts to enhance your productivity.

To perform declarative provisioning, you first need to create or obtain an ARM JSON Template. Microsoft provides plenty of examples of ARM JSON Templates in the Azure QuickStart Templates Git repository on GitHub.

To perform imperative provisioning, there are different command branches for each supported Azure platform feature. For example:

azure network
azure vm
azure storage
azure webapp
azure apiapp
azure rediscache

… and more!

Before we talk about provisioning resources, let’s cover Azure Resource Groups a bit more. We’ve already looked at how to create an Azure Resource Group, but what else can we do with them?
This command:

azure group list

…will display a list of all the Azure Resource Groups in your current subscription. The azure group delete command:

azure group delete

…will remove the specified Azure Resource Group, and all of the cloud resources that are contained within it.

If you have an existing Azure Resource Group, but want to add or remove “tags” (key-value pairs of user-defined metadata), you can use the

azure group set

command. In fact, let’s go ahead and assign a tag now. To assign a tag, use the following command:

azure group set --name CloudAcademy --tags 'Department=Marketing’

You should see a message, indicating that the command was successful:
Azure Resource Group command screenshot
That’s all we’ve got right now for ARM Resource Groups!

Join us for the next post, where we will talk about xPlat Azure CLI. And feel free to add your comments below.

Cloud Academy