• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

Microsoft Azure – Install and Configure Azure CLI on Redhat/CentOS

December 6, 2019 By Cloud_Devops 1 Comment

Microsoft Azure is one of the leading cloud service providers in the market. Azure is an industry leader in IaaS and PaaS service cloud. Azure CLI is a command-line interface for managing most of the Azure resources. The Azure portal itself provides an option to automate many things within Azure. The ARM template is one of the best examples. But the Command-Line option always provides more flexibility to integrate with other tools for building custom automation to use Azure resources.

Let’s see how to install and configure Azure CLI on Redhat Linux/CentOS. I always feel that the Linux shell is a better option to create a custom automation workflow.

Environment:

  • Operating System : Redhat Enterprise Linux 7.x / CentOS 7.x
  • Internet Connectivity

Procedure – Installing Azure CLI on Linux

1. Login to Redhat Linux /CentOS as root user. 

2. Download and execute the InstallAzureCli script from Azure. 

# curl -L https://aka.ms/InstallAzureCli | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 1369 100 1369 0 0 1936 0 --:--:-- --:--:-- --:--:-- 1936
Downloading Azure CLI install script from https://azurecliprod.blob.core.windows.net/install.py to /tmp/azure_cli_install_tmp_TMAuYk.
######################################################################## 100.0%
/tmp/azure_cli_install_tmp_TMAuYk: OK
Running install script.
-- Verifying Python version.
-- Python version 2.7.5 okay.
-- Verifying native dependencies.
-- Executing: 'rpm -q gcc libffi-devel python-devel openssl-devel'
-- Native dependencies okay.

3. Select the custom installation path to store the lib files.

===> In what directory would you like to place the install? (leave blank to use '/root/lib/azure-cli'): /opt/azure/lib/azure-cli
-- Creating directory '/opt/azure/lib/azure-cli'.
-- We will install at '/opt/azure/lib/azure-cli'.

4. Select the custom location for azure CLI binaries to store.

===> In what directory would you like to place the 'az' executable? (leave blank to use '/root/bin'): /opt/azure/bin
-- Creating directory '/opt/azure/bin'.
-- The executable will be in '/opt/azure/bin'.
-- Downloading virtualenv package from https://pypi.python.org/packages/source/v/virtualenv/virtualenv-16.7.7.tar.gz.
-- Downloaded virtualenv package to /tmp/tmpByb4x8/virtualenv-16.7.7.tar.gz.
-- Checksum of /tmp/tmpByb4x8/virtualenv-16.7.7.tar.gz OK.
-- Extracting '/tmp/tmpByb4x8/virtualenv-16.7.7.tar.gz' to '/tmp/tmpByb4x8'.
-- Executing: ['/bin/python', 'virtualenv.py', '--python', '/bin/python', '/opt/azure/lib/azure-cli']
Already using interpreter /bin/python

5. Here is Complete installation logs.

New python executable in /opt/azure/lib/azure-cli/bin/python

Installing setuptools, pip, wheel…

done.

-- Executing: ['/opt/azure/lib/azure-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpByb4x8', 'azure-cli', '--upgrade']

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Collecting azure-cli

  Downloading https://files.pythonhosted.org/packages/6e/dc/c54eea78cda6eaf5fbe7565b1a8bb2d68c4946c3abbd8d8c59daede997f7/azure_cli-2.0.77-py2.py3-none-any.whl (1.4MB)

     |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 1.4MB 2.3MB/s

Collecting azure-graphrbac~=0.60.0


  Downloading https://files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting futures; python_version < "3.0"
  Downloading https://files.pythonhosted.org/packages/d8/a6/f46ae3f1da0cd4361c344888f59ec2f5785e69c872e175a748ef6071cdb5/futures-3.3.0-py2-none-any.whl
Collecting adal~=1.2
  Downloading https://files.pythonhosted.org/packages/4f/b5/3ea9ae3d1096b9ff31e8f1846c47d49f3129a12464ac0a73b602de458298/adal-1.2.2-py2.py3-none-any.whl (53kB)
     |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 61kB 16.5MB/s
Collecting pyasn1; python_version < "2.7.9"
  Downloading https://files.pythonhosted.org/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77kB)
     |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 81kB 21.4MB/s
Collecting ndg-httpsclient; python_version < "2.7.9"
  Downloading https://files.pythonhosted.org/packages/bf/b2/26470fde7ff55169df8e071fb42cb1f83e22bd952520ab2b5c5a5edc2acd/ndg_httpsclient-0.5.1-py2-none-any.whl
Collecting cffi!=1.11.3,>=1.8

  Downloading https://files.pythonhosted.org/packages/93/5d/c4f950891251e478929036ca07b22f0b10324460c1d0a4434c584481db51/cffi-1.13.2-cp27-cp27mu-manylinux1_x86_64.whl (384kB)

     |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 389kB 61.5MB/s



  Stored in directory: /tmp/tmpByb4x8/wheels/91/95/75/19c98a91239878abbc7c59970abd3b4e0438a7dd5b61778335

Successfully built pyyaml jsondiff azure-functions-devops-build jsmin psutil sshtunnel vsts-cd-manager vsts antlr4-python2-runtime tabulate pycparser scandir

Installing collected packages: six, isodate, enum34, pycparser, cffi, ipaddress, cryptography, pyOpenSSL, idna, certifi, urllib3, chardet, requests, oauthlib, requests-oauthlib, typing, msrest, azure-nspkg, azure-common, PyJWT, python-dateutil, adal, msrestazure, azure-graphrbac, azure-mgmt-nspkg, azure-mgmt-containerservice, pyyaml, jsondiff, azure-mgmt-privatedns, azure-mgmt-web, azure-mgmt-dns, azure-mgmt-batchai, vsts, MarkupSafe, jinja2, azure-functions-devops-build, javaproperties, azure-mgmt-marketplaceordering, azure-mgmt-reservations, portalocker, azure-cli-nspkg, applicationinsights, azure-cli-telemetry, azure-mgmt-cdn, xmltodict, azure-mgmt-managedservices, azure-mgmt-eventgrid, azure-keyvault, azure-mgmt-datalake-nspkg, azure-mgmt-datalake-store, invoke, bcrypt, pynacl, paramiko, fabric, azure-mgmt-recoveryservices, azure-mgmt-datamigration, azure-mgmt-monitor, azure-mgmt-rdbms, azure-mgmt-security, azure-mgmt-iothub, pbr, funcsigs, mock, azure-mgmt-netapp, azure-cli-command-modules-nspkg, jsmin, colorama, argcomplete, monotonic, humanfriendly, azure-mgmt-resource, wheel, jmespath, antlr4-python2-runtime, futures, tabulate, pygments, knack, pyasn1, ndg-httpsclient, azure-cli-core, scp, azure-mgmt-storage, azure-mgmt-batch, azure-storage-nspkg, azure-storage-common, azure-storage-blob, azure-mgmt-deploymentmanager, scandir, pathlib2, azure-datalake-store, azure-mgmt-containerregistry, pydocumentdb, azure-mgmt-compute, azure-mgmt-redis, azure-multiapi-storage, psutil, azure-mgmt-sql, azure-mgmt-authorization, azure-mgmt-datalake-analytics, azure-cosmos, azure-mgmt-loganalytics, azure-mgmt-appconfiguration, azure-mgmt-eventhub, azure-mgmt-msi, azure-mgmt-consumption, azure-mgmt-imagebuilder, azure-mgmt-signalr, pytz, azure-mgmt-maps, azure-mgmt-advisor, azure-mgmt-devtestlabs, websocket-client, sshtunnel, azure-mgmt-billing, vsts-cd-manager, azure-mgmt-cognitiveservices, azure-mgmt-relay, azure-mgmt-containerinstance, azure-mgmt-kusto, azure-mgmt-policyinsights, azure-loganalytics, azure-mgmt-iothubprovisioningservices, azure-mgmt-sqlvirtualmachine, azure-batch, azure-mgmt-recoveryservicesbackup, azure-mgmt-keyvault, azure-mgmt-managementgroups, azure-mgmt-network, azure-mgmt-trafficmanager, azure-mgmt-applicationinsights, azure-mgmt-iotcentral, azure-mgmt-hdinsight, azure-mgmt-cosmosdb, azure-mgmt-media, azure-mgmt-apimanagement, azure-mgmt-botservice, azure-mgmt-search, azure-mgmt-servicefabric, azure-mgmt-servicebus, azure-cli

  Found existing installation: wheel 0.33.6

    Uninstalling wheel-0.33.6:

      Successfully uninstalled wheel-0.33.6

Successfully installed MarkupSafe-1.1.1 PyJWT-1.7.1 adal-1.2.2 antlr4-python2-runtime-4.7.2 applicationinsights-0.11.9 argcomplete-1.10.3 azure-batch-8.0.0 azure-cli-2.0.77 azure-cli-command-modules-nspkg-2.0.3 azure-cli-core-2.0.77 azure-cli-nspkg-3.0.4 azure-cli-telemetry-1.0.4 azure-common-1.1.23 azure-cosmos-3.1.2 azure-datalake-store-0.0.48 azure-functions-devops-build-0.0.22 azure-graphrbac-0.60.0 azure-keyvault-1.1.0 azure-loganalytics-0.1.0 azure-mgmt-advisor-2.0.1 azure-mgmt-apimanagement-0.1.0 azure-mgmt-appconfiguration-0.3.0 azure-mgmt-applicationinsights-0.1.1 azure-mgmt-authorization-0.52.0 azure-mgmt-batch-7.0.0 azure-mgmt-batchai-2.0.0 azure-mgmt-billing-0.2.0 azure-mgmt-botservice-0.2.0 azure-mgmt-cdn-3.1.0 azure-mgmt-cognitiveservices-5.0.0 azure-mgmt-compute-10.0.0 azure-mgmt-consumption-2.0.0 azure-mgmt-containerinstance-1.5.0 azure-mgmt-containerregistry-3.0.0rc7 azure-mgmt-containerservice-8.0.0 azure-mgmt-cosmosdb-0.8.0 azure-mgmt-datalake-analytics-0.2.1 azure-mgmt-datalake-nspkg-3.0.1 azure-mgmt-datalake-store-0.5.0 azure-mgmt-datamigration-0.1.0 azure-mgmt-deploymentmanager-0.1.0 azure-mgmt-devtestlabs-2.2.0 azure-mgmt-dns-2.1.0 azure-mgmt-eventgrid-2.2.0 azure-mgmt-eventhub-2.6.0 azure-mgmt-hdinsight-1.1.0 azure-mgmt-imagebuilder-0.2.1 azure-mgmt-iotcentral-1.0.0 azure-mgmt-iothub-0.8.2 azure-mgmt-iothubprovisioningservices-0.2.0 azure-mgmt-keyvault-1.1.0 azure-mgmt-kusto-0.3.0 azure-mgmt-loganalytics-0.2.0 azure-mgmt-managedservices-1.0.0 azure-mgmt-managementgroups-0.2.0 azure-mgmt-maps-0.1.0 azure-mgmt-marketplaceordering-0.2.1 azure-mgmt-media-1.1.1 azure-mgmt-monitor-0.7.0 azure-mgmt-msi-0.2.0 azure-mgmt-netapp-0.7.0 azure-mgmt-network-7.0.0 azure-mgmt-nspkg-3.0.2 azure-mgmt-policyinsights-0.3.1 azure-mgmt-privatedns-0.1.0 azure-mgmt-rdbms-1.9.0 azure-mgmt-recoveryservices-0.4.0 azure-mgmt-recoveryservicesbackup-0.4.0 azure-mgmt-redis-6.0.0 azure-mgmt-relay-0.1.0 azure-mgmt-reservations-0.6.0 azure-mgmt-resource-4.0.0 azure-mgmt-search-2.1.0 azure-mgmt-security-0.1.0 azure-mgmt-servicebus-0.6.0 azure-mgmt-servicefabric-0.2.0 azure-mgmt-signalr-0.3.0 azure-mgmt-sql-0.15.0 azure-mgmt-sqlvirtualmachine-0.4.0 azure-mgmt-storage-5.0.0 azure-mgmt-trafficmanager-0.51.0 azure-mgmt-web-0.42.0 azure-multiapi-storage-0.2.4 azure-nspkg-3.0.2 azure-storage-blob-1.5.0 azure-storage-common-1.4.2 azure-storage-nspkg-3.1.0 bcrypt-3.1.7 certifi-2019.11.28 cffi-1.13.2 chardet-3.0.4 colorama-0.4.1 cryptography-2.8 enum34-1.1.6 fabric-2.5.0 funcsigs-1.0.2 futures-3.3.0 humanfriendly-4.18 idna-2.8 invoke-1.3.0 ipaddress-1.0.23 isodate-0.6.0 javaproperties-0.5.1 jinja2-2.10.3 jmespath-0.9.4 jsmin-2.2.2 jsondiff-1.2.0 knack-0.6.3 mock-2.0.0 monotonic-1.5 msrest-0.6.10 msrestazure-0.6.2 ndg-httpsclient-0.5.1 oauthlib-3.1.0 paramiko-2.7.0 pathlib2-2.3.5 pbr-5.4.4 portalocker-1.5.2 psutil-5.6.7 pyOpenSSL-19.1.0 pyasn1-0.4.8 pycparser-2.19 pydocumentdb-2.3.5 pygments-2.5.2 pynacl-1.3.0 python-dateutil-2.8.1 pytz-2019.1 pyyaml-5.2 requests-2.22.0 requests-oauthlib-1.3.0 scandir-1.10.0 scp-0.13.2 six-1.13.0 sshtunnel-0.1.5 tabulate-0.8.6 typing-3.7.4.1 urllib3-1.25.7 vsts-0.1.25 vsts-cd-manager-1.0.2 websocket-client-0.56.0 wheel-0.30.0 xmltodict-0.12.0

-- Executing: ['/opt/azure/lib/azure-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpByb4x8', '--upgrade', '--force-reinstall', 'azure-nspkg', 'azure-mgmt-nspkg']

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Collecting azure-nspkg

  Using cached https://files.pythonhosted.org/packages/c2/95/af354f2f415d250dafe26a5d94230558aa8cf733a9dcbf0d26cd61f5a9b8/azure_nspkg-3.0.2-py2-none-any.whl

Collecting azure-mgmt-nspkg

  Using cached https://files.pythonhosted.org/packages/a1/6e/464d039ec6184234b188d6a9d199e658cce86b38afe4db0e8edd1629f3f6/azure_mgmt_nspkg-3.0.2-py2-none-any.whl

Installing collected packages: azure-nspkg, azure-mgmt-nspkg

  Found existing installation: azure-nspkg 3.0.2

    Uninstalling azure-nspkg-3.0.2:

      Successfully uninstalled azure-nspkg-3.0.2

  Found existing installation: azure-mgmt-nspkg 3.0.2

    Uninstalling azure-mgmt-nspkg-3.0.2:

      Successfully uninstalled azure-mgmt-nspkg-3.0.2

Successfully installed azure-mgmt-nspkg-3.0.2 azure-nspkg-3.0.2

-- The executable is available at '/opt/azure/bin/az'.

-- Created tab completion file at '/opt/azure/lib/azure-cli/az.completion'

6. It will prompt you to update the command search path. The script could automatically update for the current user.

===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n): y
 ===> Enter a path to an rc file to update (leave blank to use '/root/.bashrc'):
 -- Backed up '/root/.bashrc' to '/root/.bashrc.backup'
 -- Installation successful.
 -- Run the CLI with /opt/azure/bin/az --help
 [root@UA-RHEL files]#

We have successfully installed Azure CLI on Redhat Linux/ CentOS. In the upcoming article, we will see how to authenticate Azure CLI in various methods.

If you see the following errors, kindly ensure that your system has python 3.x installed.

except CLIInstallError as cie:     print('ERROR: '+str(cie), file=sys.stderr)     sys.exit(1) except KeyboardInterrupt:     print('\n\nExiting...')     sys.exit(1)
  1. You can install python 3.x on RHEL 7.x / CentOS 7.x by enabling epel repo.
# yum install -y epel-release 
# yum install -y python36 python36-pip

2. Download Azure CLI python script and store it in temporary location

# curl -L https://aka.ms/InstallAzureCli  >> /tmp/InstallAzureCli 

3. Install Azure CLI using python3 command.

# chmod +x /tmp/InstallAzureCli 
# python36 /tmp/InstallAzureCli 

References:

  • Visit https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest for more information about Azure CLI

Filed Under: Azure, Azure-CLI, Microsoft Tagged With: azcli, Azure, Azure CLI, Microsoft

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version