The Azure Command-Line Interface (CLI) is a tool that, through the use of text commands, allows users to create, configure and monitor cloud resources in an efficient and automated way, eliminating the need for graphical interfaces and facilitating integration with scripts and DevOps processes. Compatible with different operating systems, Azure CLI is dedicated to developers, system administrators and IT professionals who seek to optimize their work in the cloud and offers, in addition to great flexibility, also a learning curve accessible to the less experienced. In this article, we're going to take a closer look at how it works and what the essential commands are, and we'll also take a moment to talk about Developer CLI and the differences between Azure CLI and PowerShell.
If you are new to Microsoft Azure, your journey most likely started working within the Azure Portal, perhaps creating resources such as virtual machines and storage accounts using distribution wizards.
However, this process is tedious and doesn't scale when you need to create a lot of resources. To take the development of your software solutions to the next level, it is necessary to have a much higher degree of freedom and control, which software based on the use of a graphical interface often does not offer.
Azure CLI (short for Command-Line Interface) is a robust command-line tool provided by Microsoft for managing Azure resources. It offers a fast, flexible, scriptable way to interact with Azure services and resources, allowing users to efficiently automate tasks and manage infrastructure in the Azure cloud.
Users can use this platform to script a variety of operations in the Azure portal, such as creating or deleting Azure resources, including virtual machines or backing up SQL databases.
But how does it work specifically? Let's take a closer look at it.
Before we begin our overview, let's take a moment to better understand what a CLI is and how it works.
A CLI, or Command-Line Interface (Command Line Interface), is a user interface that allows users to interact with a computer or software system by typing text commands. Unlike graphical interfaces (GUIs), which use visual elements such as windows, icons, and menus, a CLI requires the user to enter specific commands through a keyboard.
In the CLI, the interaction therefore takes place only textually, with the commands inserted sequentially one after the other. This type of interface allows more technical users to easily write scripts, or sequences of commands, to automate repetitive tasks.
A command line interface therefore offers those who know how to use it a high level of control and freedom and allows them to perform advanced and complex operations that are often not possible with GUIs and can be much faster and more efficient for performing complex operations.
Azure CLI does exactly that for Azure services and gives developers freedom and control to come up with more technically complex solutions for all Microsoft cloud platform services, including virtual machines, storage accounts, databases, virtual networks, and more. Users can create, manage, and monitor resources directly from the command line, without the need to interface with a GUI.
In order to use it, after installing it, you run it through a shell (a program that acts as an intermediary between the user and a computer's operating system), such as CMD on Windows or Bash on Linux or MacOS, and then you type a command at the shell prompt.
The Azure CLI can be installed locally on Linux, Mac, or Windows systems. It can also be accessed through a browser using the Azure Cloud Shell or within a Docker container.
We have created the Infrastructure & Security team, focused on the Azure cloud, to better respond to the needs of our customers who involve us in technical and strategic decisions. In addition to configuring and managing the tenant, we also take care of:
With Dev4Side, you have a reliable partner that supports you across the entire Microsoft application ecosystem.
To be able to use Azure CLI on your system, all you have to do is go through a simple installation process followed by a quick configuration to connect to your Azure account. Here we'll dive into the installation steps for different operating systems and the initial configuration steps to make sure you're ready to manage Microsoft Azure resources using the CLI in no time.
/bin/bash -c “$ (curl -fSSL https://raw.githubusercontent.com/Homebrew/
install/HEAD/install.sh)”
brew update && brew install azure-cli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e “[azure-cli]\nname=Azure CLI\nbaseurl= https://packages.microsoft.com/
yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey= https://packages.
microsoft.com/ keys/microsoft.asc” > /etc/yum.repos.d/
azure-cli.rel'
sudo dnf install azure-cli
After installing the Azure CLI, the next step is to configure it by logging in to your Azure account:
Log in
az account list --output table
<Subscription Name or ID>az account set --subscription "”
Azure CLI offers an incredible amount of commands that allow you to interact with the equally numerous Azure services. Given the size, it will not be possible to cover them in their entirety; therefore, we will limit ourselves to introducing only a few fundamental commands, essential for anyone starting to use Azure CLI.
These commands cover working with resource groups and obtaining information on various Azure services and will allow those who want to start using it to have a little clearer idea of how to do it.
Before we begin, however, let's take a look at what is undoubtedly one of the most useful Azure CLI commands, namely 'help'.
The help command is a very useful tool for obtaining detailed information about the available commands, their topics and options, and its main function is to provide assistance and documentation directly on the command line, thus facilitating the use of the CLI.
When you use the 'az help' command, you get a general overview of the Azure CLI, including the main commands and extensions available, extremely useful for finding your way around and understanding which commands are available for use.
You can also obtain detailed information about a specific command by adding help after the command of interest. This provides details about the command topics, the options available, and often includes examples of use. Below is an example of this possible use:
AZ Group Help
To get details about a specific action of a command, you can further extend the use of help. This is useful for exploring all the possible actions and parameters of a given command. Let's take up the example above and see how the syntax changes:
AZ Group Create Help
You can also use the '—help' syntax with any command to get detailed information. This works identically to adding help at the end of the command. Below is another example:
Do vm create --help
Resource groups are containers that host related resources for an Azure solution. Here's how to quickly create and manage resource groups using the Azure CLI:
<Insert Name>az group create --name --location <Insert Regione>
This command will create a new Resource Group. Remember to enter a name for the resource and its location in the command based on the Azure region of the account.
az group list --output table
az group delete --name --yes <InsertResourceName>--no-wait
The --yes flag confirms the operation, and --no-wait tells the CLI not to wait for the operation to complete before returning to the prompt.
As we already mentioned at the beginning of the section, Azure CLI can interact with practically all Azure services. Let's take a couple of examples to better understand how:
Az vm list --output table
This command will list all the vms in the selected default subscription, showing their names, associated resource groups, and locations.
az storage account list --output table
Similar to the previous command, it will show a table of all storage accounts showing their associated names, locations, and resource groups.
Azure Virtual Machines (VMs) are one of the most commonly used resources. They allow you to deploy and manage virtual servers in the cloud. Here's how you can manage VMs using Azure CLI:
Do vm create\
<InsertResourceName>--resource-group\
--name MyVM\
--image UbuntuLTS\
<InsertUserName>--admin-username\
--generate-ssh-keys
<InsertResourceName>az vm start --resource-group --name MyVM
<InsertResourceName>az vm stop --resource-group --name MyVM
Azure CLI can also be used to manage Apps created and distributed through the Azure App Service service. Here are also some examples of usable commands:
<InsertResourceName>az appservice plan create --name <InsertPlanName>--resource-group --sku F1 --location <InsertRegion>
(Please specify that this command specifically creates a free tier Service Plan).
<InsertResourceName><InsertPlanName>az webapp create --resource-group --plan --name <InsertAppName>
Azure CLI can also be used to manage and upload files to your Azure Storage accounts. Again, let's take a couple of more concrete examples to see how it works in this context:
az storage account create\
<InsertStorageAccountName>--name\
<InsertResourceName>--resource-group\
<InsertRegion>--location\
--SKU standard_LRS
With this specific command, we are going to create a storage account that uses “Standard_LRS” (Locally-redundant storage) as a redundancy option in the desired region.
Do storage blob upload\
<InsertStorageAccountName>--account-name\
<InsertContainerName>--container-name\
<InsertFileName>--name\
--file <InsertPathToFile>
Before using the command, make sure that there is a container in your storage account.
The Azure Developer CLI is a primarily developer-oriented tool. This tool is designed to create and deploy Azure applications and infrastructure using just a few commands. It is like Azure CLI, an open-source tool and has two main objectives: to reduce development time and to help developers understand the fundamental concepts of developing on Azure.
Both allow you to distribute services and infrastructures on Azure but Azure CLI is a more general tool that allows you to manage and control Azure resources directly from the terminal, with a lot of freedom to modify, change and have more detailed control over each command executed.
The Azure Developer CLI, on the other hand, is a more developer-oriented tool, focused on accelerating distributions by having many aspects already connected for the user within a single application, giving developers the opportunity to have less concern about the distribution process.
A typical use case of the Azure Developer CLI is if you have a complete application consisting of multiple complex services that connect to each other. In this particular case it would be a very difficult task to configure them manually in the portal or through many commands through Azure CLI.
The handful of developer-friendly commands that can be used within this interface allows you to take care of all the key steps in a developer's workflow without having to get lost in the manual configuration of every single connection and service and can be particularly useful if you are working in a team and you want to be sure that everyone is using the same infrastructure and app code.
Azure CLI and PowerShell are two of the main tools for managing and automating Azure services, but even if they appear to be the same tool, they couldn't be more different. In fact, many novice users may confuse them because both are command-line based, but the difference between Azure CLI and PowerShell is the equivalent of the difference between a program and an operating system. Let's take a better look at it.
Azure CLI, as we have already seen, is a tool designed specifically to work with Azure services. It is focused on interacting with the Azure platform through a series of commands with an intuitive and uniform syntax (facilitating the learning and use of the tool), regardless of the operating system in use and to be used it needs to be installed on a shell from which it will then be executed.
PowerShell, on the other hand, is a command-line shell and a scripting language created by Microsoft, initially to manage Windows systems but then extended to other environments, becoming compatible with Windows, macOS and Linux after the introduction of PowerShell Core, significantly expanding its reach.
The latter, unlike CLI, is a real command console (like Linux bash or the old Windows CMD) and offers a syntax based on commands and objects, which means that the results of operations are treated as objects and not as simple text and is often used for managing Windows environments and for the automation of more general activities.
Powershell integrates Azure-specific cmdlets, which offer greater depth of control and customization than the basic Azure CLI commands (albeit at the cost of greater complexity and difficulty in writing and reading) but its functionality is not limited to Azure alone, making it particularly suitable for complex scenarios where it is necessary to integrate Azure with other system operations and complex scripts.
In actual practice, many users use a combination of Azure CLI and PowerShell based on their specific needs and preferences, and these tools are complementary rather than exclusive to each other, and the choice often depends on the task at hand. When choosing which command-line tool is most suitable, you should therefore consider your experience and the type of environment in which you work to be able to exploit the two to their full potential.
The possibility of having greater freedom and control offered by command line interfaces is the reason why, after many more years, many experienced developers prefer them over solutions with a graphic interface that, although more user-friendly and easy to use, could be subject to uncomfortable limitations.
With its offer, Azure CLI has essentially made the work of developers who prefer the use of this type of more minimal interfaces much faster, more understandable and more concise, managing to guarantee them the same degree of control and freedom of action over their work with greater ease and less effort.
With its combination of versatility and intuitive, no-frills language, as well as the ability to use it on multiple platforms (and even browsers) without compatibility problems with different shells, the Azure command line interface has become over time one of the most popular solutions for developers working on Microsoft's cloud computing platform. So why not put it to the test and discover its potential for yourself?
Azure CLI is a command-line tool provided by Microsoft to manage Azure resources. It enables efficient automation and management of cloud infrastructure through text commands, offering more control compared to graphical interfaces.
Azure Developer CLI is a specialized tool for developers, focusing on simplifying the development and deployment of Azure applications, offering streamlined commands for managing complex services and infrastructure.
Azure CLI operates through text commands in a terminal or shell, allowing users to create, configure, and monitor Azure resources. It can be installed on Windows, macOS, or Linux, and used locally or via a browser through Azure Cloud Shell.
To install Azure CLI on Windows, download the MSI installer from the official Azure CLI download page, run it, and follow the installation wizard. Once installed, open Command Prompt or PowerShell and type az
to start using Azure CLI.
Yes, you can install Azure CLI on macOS using Homebrew. First, install Homebrew, then use the command brew update && brew install azure-cli
in Terminal to install Azure CLI.
Some essential Azure CLI commands include:
az group create
to create a resource group.az vm list
to list virtual machines.az storage account list
to list storage accounts.Azure CLI is specifically designed for managing Azure services with a consistent command structure, while PowerShell is a more general-purpose shell and scripting language with deep integration into Windows environments.
The Infra & Security team focuses on the management and evolution of our customers' Microsoft Azure tenants. Besides configuring and managing these tenants, the team is responsible for creating application deployments through DevOps pipelines. It also monitors and manages all security aspects of the tenants and supports Security Operations Centers (SOC).