The Azure CLI is the cross-platform, command-line tool for managing resources in Microsoft Azure. Microsoft recently released the Azure CLI 2.0 and the commands start with az instead of azure like Azure CLI 1.0. This article runs through the main differences between Azure CLI 1.0 and Azure CLI 2.0 to help you understand how to use each one.

Installation and Platform

When the Azure CLI 1.0 was first released it was call the X-Plat CLI, and offered a new cross-platform command-line tool to use for Azure automation tasks. It offered an alternative to the Azure PowerShell cmdlets that gave a command-line tool for use on macOS and Linux, in addition to Windows. In the early days it was built on top of the Azure Service Management API’s, and has since been migrated over to support the newer Azure Resource Management API’s.

The new Azure CLI 2.0 was built with Azure Resource Management (ARM) from the start. It was also built with the lessons learned from 1.0 in mind to make 2.0 a better cross-platform, command-line tool. The development platform and language used to build the Azure CLI 2.0 was changed, and the commands essentially changed a bit in the process. It’s really not an “in-place” migration, and requires you to understand a little more than to just install the new version.

The Azure CLI 1.0 was written with Node.js to achieve cross-platform capabilities, and the new Azure CLI 2.0 is written in Python to offer better cross-platform capabilities. Both are Open Source and available on Github.

Azure CLI 2.0 is written in Python, Azure CLI was written in JavaScript. Both are Open Source!

Here’s the platform differences between the 2 version of the Azure CLI along with links where you can find the Open Source repository for each:

Azure CLI 1.0

Azure CLI 2.0

Azure CLI Installation

Since the Azure CLI is cross-platform it can be installed on Windows, macOS, and Linux. This is true for both the Azure CLI 1.0 and Azure CLI 2.0. Since the Azure CLI 1.0 is written with Node.js, it will require Node.js to be installed on your machine. While the Azure CLI 2.0 is written in Python, and requires Python.

Azure CLI 1.0 Installation

Here’s commands to install Azure CLI 1.0 at the command-line using Node.js:

sudo npm install -g azure-cli

Use a Docker Container to run the Azure CLI 1.0:

docker run -it microsoft/azure-cli

You can also use an installer with Windows and macOS to install the Azure CLI 1.0 more easily as well. You can find the installers for the Azure CLI 1.0 on the Github repository.

Azure CLI 2.0 Installation

Here’s commands to install Azure CLI 2.0 on different platforms. Keep in mind that it does require Python.

Windows Command-Line

You can download the .MSI installer for Azure CLI 2.0 to install the Windows command-line support for Azure CLI.

Bash on Windows 10

The Ubuntu Bash on Windows 10 can be used to run the Azure CLI 2.0 while utilizing it’s full support for Bash and on a Windows 10 machine at the same time.

  1. First step, if you don’t have Bash on Windows installed (Ubuntu Bash on Windows 10, or the newer (coming soon) support for SUSE and Fedora on Windows 10 too!) then install it!
  2. Using Bash, modify your sources list:
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \ sudo tee /etc/apt/sources.list.d/azure-cli.list

Run the following sudo commands to install the Azure CLI 2.0:

sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install azure-cli

macOS and Linux

Here’s the installation command to install the Azure CLI 2.0 on macOS as well as Linux using Curl:

curl -L https://aka.ms/InstallAzureCli | bash

Additionally, you may need to restart your command-lim in order for some changes to take affect. You can do this with the following command:

exec -l $SHELL

Docker Container

You can also run the Azure CLI 2.0 in a Docker Container fairly easily. Here’s the “docker run” command to do this:

docker run azuresdk/azure-cli-python:<version>

apt-get on Linux

You can also use the following commands to install Azure CLI 2.0 on Linux using apt-get.

On 32-bit systems:

echo "deb https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list

On 64-bit systems:

echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list

After you run the above 32-bit or 64-bit specific command, then you’ll need to run the following sudo commands as well:

sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install azure-cli

There is some further documentation for installing the Azure CLI 2.0 available in the Azure Documentation site.

Getting Started with Azure CLI Commands

Both the Azure CLI 1.0 and 2.0 have very similar commands. However, the command start differently. With the Azure CLI 1.0 commands start with “azure” and with the Azure CLI 2.0 command start with “az”.

Before you can go about running Azure CLI commands, you need to first login to your Azure Subscription. Here are commands to do this in both Azure CLI versions:

# Azure CLI 1.0
azure login

#Azure CLI 2.0
az login

To get a full list of the available commands and full help information you can run the following command:

# Azure CLI 1.0
azure

# Azure CLI 2.0
az

Also, you can find the version of Azure CLI you have installed by using the following command:

# Azure CLI 1.0
azure --version

# Azure CLI 2.0
az --version

Azure CLI Command Examples

Here’s some example commands using both the Azure CLI 1.0 and Azure CLI 2.0. You can see that they aren’t really all that different outside of the trigger command of either “azure” or “az”.

Create New Azure Resource Group

# Azure CLI 1.0
azure group create --name MyGroup1 --location eastus

# Azure CLI 2.0
az group create --name MyGroup1 --location eastus

Create Azure App Service Plan

# Azure CLI 1.0
azure appserviceplan create --name MyPlan --resource-group MyGroup1 --location eastus --sku F1

# Azure CLI 2.0
az appservice plan create --name MyPlan --resource-group MyGroup1 --location eastus --sku F1

List All Azure Virtual Machines

# Azure CLI 1.0
azure vm list

# Azure CLI 2.0
az vm list

More Information

You can find much more information about using the Azure CLI 1.0 and 2.0 in the documentation on the Open Source project sites hosted on Github, and in the Microsoft Azure documentation. Here’s some link to those resources:

Also, don’t forget to try out the new Azure Cloud Shell to use bash with both the Azure CLI 1.0 and Azure CLI 2.0 command directly in the Azure Portal from anywhere!

Happy cross-platform, command-line scripting in the cloud!!

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.

Discover more from Build5Nines

Subscribe now to keep reading and get access to the full archive.

Continue reading

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |