Azure CLI – Installation and Uses

Azure CLI – Installation and Uses

Azure CLI – Installations & Uses

Technology keep evolving and we all know we are in the era of clouds. Many major players in cloud technology like AWS, Azure, and Google with many other names in it. Azure CLI is just command line interface provided by Microsoft Azure .All is providing GUI based platforms to manage your IT infrastructures like Web Portals or you can say consoles.

These are really friendly for most of the IT infrastructure Professionals but there are thousands of professionals from unix linux background who does not feel accomplished if they use GUI tools. They love using commands to get things done and having full command over what exactly they are doing and what is expected results.

Many professionals feel accomplished using command line utilities and they are really needed to automate things. So come Command Line Interface always referred as CLI. Azure CLI is the same.

What is Azure CLI?

Azure CLI is Microsoft’s cross-platform command-line for managing Azure CLOUD Resources. Azure CLI designed in a way to make it easy to learn and get started with easily.Azure CLI is powerful enough great tool for automating use of Azure Resources. The current version of the Azure CLI is 2.0.81.

Key Features of Azure CLI

  • It is cross-platform can be installed in Windows and Linux environment.
  • It can be run in Docker and Azure Cloud Shell.
  • It offers command-line flexibility when managing an Azure solution.
  • It supports long-running operations.
  • It have ability to use one subscription for all commands, or vary subscriptions per command.
  • It have flexibility to work with multiple clouds.
  • It provides configurable settings.
  • It is deployed with Azure Resource Manager (ARM) deployment templates.

How to install Azure CLI

Based on your environment this procedure might be little-bit different .In our example if your environment is connected with Azure you can install Azure CLI in your onprem servers.Once you install you can start automation related to your Azure Cloud Environment.In current example we are looking at the procedure how we can install on Redhat Enterprise Linux.

You need to have python3 running on your linux server.In normal Redhat repository python2.X is getting delivered .Considering more demand for the growing use of python3 in various projects across many technologies redhat provides support for the same.

1.Validate what version of python is already running on your server using below.

# rpm -qa |grep -i python*

You can easily found which version of python is already running on your server.

2.Now you can install Python 3 using below command.It gets installed with dependencies.# # yum --enablerepo=*  install rh-python36.x86_64
Package                     Arch                    Version                             Repository                 Size
rh-python36                           x86_64                  2.0-1.el6               ondemand                  3.2 k
Installing for dependencies:
rh-python36-python               x86_64                  3.6.3-3.el6           ondemand                   54 k
rh-python36-python-devel     x86_64                  3.6.3-3.el6           ondemand                  918 k
rh-python36-python-libs        x86_64                  3.6.3-3.el6           ondemand                  7.4 M
rh-python36-python-pip         noarch                  9.0.1-2.el6             ondemand                  1.8 M
rh-python36-python-setuptools   noarch            36.5.0-1.el6           ondemand                  585 k
rh-python36-python-virtualenv    noarch                  15.1.0-2.el6     ondemand                  1.8 M
rh-python36-runtime                  x86_64                  2.0-1.el6         ondemand                  1.0 M
scl-utils                               x86_64                  20120927-29.el6_9 distro                     23 k
scl-utils-build                    x86_64                  20120927-27.el6_6  ondemand                   17 k
Transaction Summary
Install      10 Package(s)
Total download size: 14 M
Installed size: 54 M
Is this ok [y/N]: y
You can enquire about installed version of python. 

[[email protected] ]# rpm -qa |grep rh-python

Once you install Python3 you need to configure it by creating links so it works as expected because you already have old version in server.
# ln -s /opt/rh/rh-python36/root/usr/bin/python /usr/bin/python3.6
# ln -s /opt/rh/rh-python36/root/usr/bin/python /usr/bin/python

3.We have met pre-requirement. Now for installing Azure CLI we will be working over internet so need to make sure your server is connected to internet and there is no firewall blocking traffic.If so you can run below command to enable traffic though internet on port 8080.Proxy setting you can use your own based on your environment.
# export http_proxy=
# export https_proxy=

4.Installing Azure CLI

Then import microsoft keys using below command.
# rpm --import
# umask 022
Setup Azure-cli.repo in /etc/yum.repos.d.
#vi /etc/yum.repos.d/azure-cli.repo        and add the below contents to the file.
name=Azure CLI

Now change to directory where you want to download rpm package.For example /tmp.
# cd /tmp
# yumdownloader azure-cli
You will have rpm package downloaded in /tmp.Make sure there was no error reported during yumdownloader command.Now you can install rpm with no dependency option.
# rpm -ivh --nodeps azure-cli-*.rpm
Make sure clean installation of azure-cli package and you are set.

Validate Azure CLI Functionality

login to the server as normal id and set proxy as explained above if needed.You can set .profile of your,s to avoid proxy setting everytime.

# az –version

command-modules-nspkg              2.0.3

core                              2.0.81

nspkg                              3.0.4

telemetry                          1.0.4

Python location ‘/usr/bin/python3’

Extensions directory ‘/home/user/.azure/cliextensions’

Python (Linux) 3.6.3 (default, Jan  9 2018, 10:18:08)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]

Legal docs and information:

Your CLI is up-to-date.

Please let us know how we are doing:

$ az account show


  “environmentName”: “AzureCloud”,

  “id”: “AZUREID”,

  “isDefault”: true,

  “name”: “SUBSCRIPTION”,

  “state”: “Enabled”,

  “tenantId”: “TENANTID”,

  “user”: {

    “name”: “[email protected]”,

    “type”: “user”



$ az login

To sign in, use a web browser to open the page and enter the code A83BG7Y4V to authenticate.

Once you try to login to azure you will get message like this.You need to open device url mentioned above and need to enter code and that,s it.You can login to azure with your defined role you can perform tasks as per level of role you have.

Below are few other common commands for reference while working with Azure CLI based on groups.It will have variants.

Resource type   Azure CLI command group
Resource Group az group
Virtual Machines az vm
Storage Accounts az storage account
Key Vault az keyvault
Web Applications az webapp
SQL Databases  az sql server
CosmosDB az cosmosdb

    That,s it as of now all about Azure CLI installation and Uses.          

Raj Rai

Raj Rai is an experienced IT Infrastructure Professional with more than 15 years of experience in IT Infrastructure Management. Raj Raj have keen interest in sharing his real world experience in his spare time as his social responsibility for IT infrastructure field. This is his contribution for IT infrastructure management sector for either newbie or even experienced professionals in unix linux cloud network and storage administration field.

Leave a Reply