Azure is Microsoft's cloud platform that offers both individuals and companies a scalable, agile and highly available IT infrastructure and services.

This guide shows you how to install and run Azure CLI commands on Ubuntu. Azure CLI is one of the tools the Microsoft Azure team provides for managing your cloud infrastructure from the command line.

Why use Azure CLI?

The Azure Command Line Interface (CLI) is a cross-platform command line tool for creating and managing Azure resources. The main purpose of this tool is to allow you to easily automate tasks by running interactive commands in your terminal or using scripts.

You can install Azure CLI on macOS, Windows, and Linux. You can also use the Azure CLI in a browser via the Azure Cloud Shell or in a Docker container.

The benefits of the Azure CLI include:

  • Easily automate the provisioning and decommissioning of resources.

  • Helps you with your DevOps operations.

  • Simplify the management of your cloud infrastructure.

Install Azure CLI on Ubuntu

To make installation easier, this guide uses the installation script maintained by the Microsoft Azure CLI team.

note: For security reasons, it is advisable to check scripts that you download from the Internet before you run them on your PC or server. This is to ensure that they do not contain any harmful content.

Use the Curls Command to download the script and then route the output to your bash shell to initialize the installation.

sudo curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

After the installation is complete, verify that the Azure CLI was installed successfully by checking the version number with the following command:

az –version

The output should be similar to the following.

azur_cli_version-1

Sign in to Azure

If you don't have an Azure account, you can create a free trial account through the Azure portal.

To manage your Azure cloud infrastructure using the Azure CLI, you must first sign in to Azure using the following command:

az login

The system will then redirect you to the standard browser. Here you have to enter your access data in order to log in. Once you are done, you will be taken back to the terminal window.

note: If you are using a non-graphical user interface, you will receive a token that you can use to log in to a browser from another device.

In the terminal, the Azure CLI gives you a brief overview of the subscriptions linked to your Azure account in JSON format.

Azure CLI gives you all of the power and functionality available in the Azure portal.

Change the output format

By default, Azure CLI formats your output in JSON format. This can take up a lot of your terminal space. Alternatively, you can use the table output format by using the -o table Option in your commands.

For example, try the az login Command again, but this time use the –o table Possibility as follows:

az login -o table

Output:

az_login_in_table_form

Choosing a subscription

Run the following command to get a list of all the subscriptions for your Azure account:

az account list -o table

If you have multiple subscriptions, you can change the default subscription with the following command:

az account record subscription –subscription & # 39; your_subscription_name & # 39;

If you renew your subscription with the az account list -o table, You have the column Is standard to adjust True for the subscription you selected.

Collection of resources

Resource groups are a very important concept in Azure. They are the logical containers in which you group logically related resources and services for easy management.

Knowing your resources is important not only for managing your infrastructure, but also for controlling cloud spending and performing optimizations.

To get a list of all active resources in a subsection, you can run the following command.

az resource list -o table

Learn more: AWS vs. Microsoft Azure: Which Cloud Service is Best?

Get command line help

One of the most powerful features of the Azure CLI is the built-in help function. You can use it to learn more about commands that you can use.

To list all of the available Azure CLI commands, just run the following command. The system shows you a list of all basic commands.

az

From this output you can choose which command you want to learn more about. For example, to find out more about the vm (virtual machine) command:

az vm –help

It shows you commands that you can run on a virtual machine. Example: starting and stopping a VM or listing VMs.

You can go even further by getting more help on a particular action. For example, to learn more about how to stop a VM:

az vm stop –help

Azure CLI shows you the command options to stop a VM, including sample commands to use it.

Related: Learn how to deploy and configure a virtual machine in Azure

Using the Azure CLI interactively

Azure CLI enables you to execute commands interactively so that you can work more efficiently. You won't find the Interactive Shell installed by default, but Azure CLI will install it automatically the first time you run it az interactive Command.

Issue the following command to start using Azure interactively.

az interactive

Output:

az_interactive_cli

Update the Azure CLI

Updating your Azure CLI is important not only for security, but also for getting new API functionality to interact with your cloud infrastructure. You can easily update your Azure CLI with the following command.

az upgrade

noteNote: The upgrade feature is only available for Azure CLI version 2.11.0 or higher.

Configure Azure CLI

In this guide we have most of the commands with the -o table Flag to get a more compact output without taking up a lot of terminal space.

To configure the table format as your standard standard output, run the following command:

Configure az

Press Yes on your keyboard when the system asks if you want to configure the Azure CLI settings. Then enter the number that appears next to the output format of your choice. For example around. to adjust table Enter as the default format 3.

azure_cli_configure_settings

In addition to changing the output format, you can also make changes to telemetry settings, logging, etc.

Log out

Use the following command to sign out of the Azure CLI.

sign off az

Uninstall the Azure CLI

If you no longer need Azure CLI on Ubuntu, you can uninstall it with the following command:

sudo apt-get remove -y azure-cli

To remove Azure CLI repository information:

sudo rm /etc/apt/sources.list.d/azure-cli.list

Real-life applications from Azure Services

This guide showed you how to install and set up the Azure CLI to manage your cloud infrastructure. There are many services that Azure provides to drive your digital transformation and to relieve the burden of managing your own IT infrastructure.

The most important services that Azure provides include artificial intelligence (AI) and machine learning (ML). Find out more about how Volkswagen uses Azure to power its self-driving cars.

A self-driving car

Volkswagen uses Microsoft Azure in self-driving cars

It's another huge hit for Microsoft as it begins to expand its network into the self-driving car market.

Continue reading

About the author

Mwiza Kumwenda
(33 published articles)

Mwiza is a professional developer of software and writes extensively on Linux and front-end programming. His interests include history, economics, politics, and corporate architecture.

More
By Mwiza Kumwenda

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

Click here to subscribe