AZ-900-EN

【AZ-900】Azure CLI vs Azure PowerShell: Understanding the Differences

【AZ-900】Azure CLI vs Azure PowerShell_ Understanding the Differences

Hi, I’m Makoto, a freelance engineer.

While Azure allows you to manage resources through the Azure Portal GUI tool, it also provides tools for managing resources through command-line operations.

  • Azure CLI
  • Azure PowerShell

These Azure tools are also covered in the AZ-900 exam, so in this article I’ll provide an overview of each tool, their differences, which one you should use, and the criteria for choosing between them.

Let’s get started!

What is Azure CLI?

Azure CLI is a command-line tool for operating Azure. You can install and use it locally on Linux, Mac, or Windows.

Reference:

Please refer to the following official documentation for installation instructions:
How to install the Azure CLI

Azure CLI commands are written as az <resource type> <verb>. For example, to create a resource group, you would run the following command with parameters that specify the name and region:

az group create --name SampleRG --location japaneast

 

Creating a resource group with Azure CLI The results of the command execution are output in JSON format. If you check the Azure portal, you can see that a resource group named “SampleRG” has been created.

SampleRG

What is Azure PowerShell?

Azure PowerShell is also a command-line tool for operating Azure that can be installed and used locally on Linux, Mac, or Windows.

Reference:

Please refer to the following official documentation for installation instructions:
How to install Azure PowerShell

You might think of PowerShell as the successor to the command prompt that comes with Windows, but you can also use it on Linux and Mac if you install it.

Even on Windows, Azure PowerShell is not available by default, and you must install the Azure PowerShell module as an add-on.

Azure PowerShell commands are written in the form of <verb>-Az<resource type>. As before, to create a resource group, you would run the following command with parameters that specify the name and region:

New-AzResourceGroup -Name SampleRG -Location japaneast

 

Creating a resource group with Azure PowerShell

Azure CLI vs Azure PowerShell

Now that we understand that there are two command-line tools, Azure CLI and Azure PowerShell, you might be wondering:

Which one should I choose?

In general, people familiar with Linux shell scripting tend to choose Azure CLI, while people familiar with Windows PowerShell tend to choose Azure PowerShell.

If you’re using it for work, it’s important to consider which tool your team members are more comfortable with.

In my experience, Azure CLI feels more intuitive and easier to understand, with a lower learning curve.

On the other hand, PowerShell is a type of object-oriented programming language, so you can store and reference variables as objects, and exception handling is easier with try-catch.

Roughly speaking, Azure PowerShell is better suited for handling more complex operations.

Consider your previous experience, learning costs, and the complexity of the operations you want to perform when making your choice. Deciding based on whether your server environment is Windows or Linux is also an option. If it doesn’t matter which one you use, I recommend trying it out with Azure CLI.

Incidentally, I started with Azure PowerShell because I was a hardcore Windows user, but after studying Linux, I came to prefer Azure CLI. In real-world environments, the choice often depends on the server operating system.

One point likely to be asked in the AZ-900 exam is that both tools work on Linux, Mac, and Windows (i.e., they are cross-platform).

Key Points:

Both Azure CLI and Azure PowerShell run on Linux, Mac, and Windows.

If you want to try Azure CLI or Azure PowerShell, Azure Cloud Shell is convenient. I’ve explained how to use it in this article, so please refer to it.

【AZ-900】What is Azure Cloud Shell_ Beginner's Guide to Getting Started
【AZ-900】What is Azure Cloud Shell? Beginner's Guide to Getting StartedHi, I'm Makoto, a freelance engineer. In this article, I'll be ex...

Summary

In this article, we’ve explained the differences between Azure CLI and Azure PowerShell.

As you become more familiar with Azure, command-line operations become convenient. They’re useful for repeating the same process or sharing procedures with others.

The official documentation also provides tutorials to help you learn the commands:

Please try them out and get hands-on experience.

View Azure Courses