Managing Azure Workloads with Azure CLI

There are multiple ways to manage your workloads on Microsoft Azure, and some of them are very intuitive like the GUI web-based interface or the Azure PowerShell module for PowerShell aficionados. But one tool among all of the available ones that attracted my attention is Azure CLI.

Azure CLI is a cross-platform command line tool that can be installed on any OS (MacOS, Windows, or Linux) and is as powerful as impressive, when using it to automate all kinds of things in the Azure Cloud infrastructure.

So If you’re managing Cloud workloads from your macOS or Linux station, this great tool will bring more fun to your automation journey in Azure.

At the time of this writing, it is on version 2.0. In this post, we will install Azure CLI on a CentOS 7 box and explore some basic features by creating an Azure resource group and spinning-off a VM inside it. Let’s get started.

Installing Azure CLI


Installation is straight forward. First we need to import the required repository key then go ahead with actual installation.

  • Importing the Microsoft repository key

  • Creating local azure-cli repository information

  • Installing Azure CLI

  • Checking the Azure CLI successful installation

You can simply type az to check if the installation went fine

 

Connecting to Azure through Azure CLI


Once you’re sure your Azure CLI installation is successful, you first need to login to Azure with the az login command.

As soon as you run this command, a browser window will prompt pointing to the Azure Web Portal and inviting you to enter your Azure credential.

Type your Azure username and password and once the authentication is done, the page be will redirected to the Azure CLI documentation.

If you have any issue with your browser display, disable temporary selinux on your host.

If the is authentication process is successful, you will have an output similar to this.

As an alternative to the Web Portal authentication, you can also use the following command for a CLI based authentication, where <username> is your Azure username.

 

Creating Azure Resources with Azure CLI


  • Creating a Resource Group

Here is an overview of the current Resource Groups in the Azure Dashboard.

Let’s start by creating a Resource Group named testRG in West Europe region.

Resource Group created! And we can confirm that testRG is there from the Azure Web Console.

  • Listing existing available images

To list all available images that can be used for VM creation, use below command.

  • Launching VMs on Azure VMs

Time now to spin-off a VM inside the testRG created previously from a Windows Server 2016 Datacenter image. I’m going for a smaller VM size with Basic_A1.

In less than 30 seconds, my VM was already running and accessible from the Azure Portal.

This was really a quick overview of what Azure CLI is and what it can bring to the table for your Azure daily administration. You can now head over the official documentation to get a better idea of its features and explore some detailed and great examples for both Windows and Linux VMs related to this tool.

Find this post interesting. Share it!

Leave a Comment

Your email address will not be published. Required fields are marked *