How To Install And Configure Azure CLI
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In this blog post, we will discuss how to install and configure Azure CLI on different popular operating systems including Windows, RedHat, Ubuntu, etc.
What Is Azure CLI:
Azure Command Line Interface or Azure CLI is a collection of commands that can be used to interact with Azure service. Like in AWS we use AWS CLI or in GCP we use gcloud, in Azure you can use Azure CLI to create and manage your Azure resources.
Prerequisites:
- One active Microsoft Azure account.
How To Install Azure CLI:
How To Install Azure CLI On Windows OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
############################################ ## How To Install And Configure Azure CLI ## ############################################ ## ---------- ## Windows OS ## ---------- ## Open a PowerShell session as admin and execute below command to install Azure CLI on windows Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi; ## Close the session and reopen |
How To Install Azure CLI On MAC OS:
1 2 3 4 5 6 7 8 9 |
## ------ ## MAC OS ## ------ # Install homebrew if not installed already /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" # install Azure CLI on MAC OS brew update && brew install azure-cli |
How To Install Azure CLI On Debian OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
## --------- ## Debian OS ## --------- ## Get packages needed for the install process sudo apt-get update sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg ## Download and install the Microsoft signing key curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null ## Add the Azure CLI repository AZ_REPO=$(lsb_release -cs) echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list ## Update repository information and install the azure-cli package sudo apt-get update sudo apt-get install azure-cli |
How To Install Azure CLI On Ubuntu OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
## --------- ## Ubuntu OS ## --------- ## Get packages needed for the install process sudo apt-get update sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg ## Download and install the Microsoft signing key curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null ## Add the Azure CLI repository AZ_REPO=$(lsb_release -cs) echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list ## Update repository information and install the azure-cli package sudo apt-get update sudo apt-get install azure-cli |
How To Install Azure CLI On RedHat Enterprise Linux (RHEL) OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## ------- ## RHEL OS ## ------- ## Import the Microsoft repository key sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc ## Create local azure-cli repository sudo sh -c 'echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' ## Install Azure CLI with the yum install command sudo yum install azure-cli |
How To Install Azure CLI On Fedora OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## --------- ## Fedora OS ## --------- ## Import the Microsoft repository key sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc ## Create local azure-cli repository sudo sh -c 'echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' ## Install Azure CLI with the yum install command sudo yum install azure-cli |
How To Install Azure CLI On CentOS OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## --------- ## CentOS OS ## --------- ## Import the Microsoft repository key sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc ## Create local azure-cli repository sudo sh -c 'echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' ## Install Azure CLI with the yum install command sudo yum install azure-cli |
How To Install Azure CLI On openSUSE OS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
## ----------- ## openSUSE OS ## ----------- ## Install curl sudo zypper install -y curl ## Import the Microsoft repository key sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc ## Create local azure-cli repository sudo zypper addrepo --name 'Azure CLI' --check https://packages.microsoft.com/yumrepos/azure-cli azure-cli ## Update the zypper package index and install sudo zypper install --from azure-cli azure-cli |
Next, we are going to configure Azure CLI.
How To Configure Azure CLI:
Open command prompt or bash and execute below command. It will open your default browser and ask for your Azure username and password.
1 2 3 4 5 6 7 8 9 |
## ------------------- ## Configure Azure CLI ## ------------------- ## Confirm if Azure CLI was installed successfully az --version ## Open command prompt or bash and execute below command az login |
Note: If your OS doesn’t have a browser, you will get an 8-digit code that you have to enter in below URL from another OS which has a browser.
Getting Help On Azure CLI Commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
## ------------ ## Getting Help ## ------------ ## list all Azure CLI commands az ## get help for a specific Azure CLI command az account --help az account show --help ## search for a command az find account ## execute your 1st Azure CLI command az account show |
Hope you have enjoyed this blog post. Please refer below Azure documentation for more details
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
https://docs.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest
https://docs.microsoft.com/en-us/cli/azure/