Azure CLI (Command-Line Interface) is a set of command-line tools provided by Microsoft for managing resources in Microsoft Azure, which is a cloud computing platform. Azure CLI allows users to interact with Azure services and resources directly from the command line, making it easier to automate tasks, script workflows, and manage Azure resources efficiently.
- Up and running ubuntu 22.04 LTS machine.
- Basic knowledge in linux commands.
- Internet connectivity.
In this post, We will show you how to install Azure CLI command line tool on ubuntu 22.04 LTS linux machine.
Step 1: Run System Update
Run the following command to make sure your package lists are up-to-date.
sudo apt-get update
Step 2: Upgrade System Packages
We need to use the given command to upgrade the default package on ubuntu 22.04 LTS machine.
sudo apt-get upgrade -y
Step 3: Adding Repository
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Step 4: Installing Azure CLI
Use the following command to install the Azure CLI.
sudo apt-get install azure-cli -y
Step 5: Verify Installation
After the installation is complete, you can verify it by running.
This should display the version number of the Azure CLI if the installation was successful.
Step 6: Login with Azure
Use the following command to log in to your Azure account.
Follow the instructions to complete the login process.
- The command will prompt you with a message to open a web page in your default browser and enter a code. This is part of the device login authentication flow.
- Open a web browser and navigate to the provided URL.
- Enter the code displayed in the terminal.
- Sign in with your Azure account credentials in the browser.
- Once you’ve successfully signed in, return to the terminal.
The Azure CLI will display information about the subscriptions associated with your account, confirming that you are now logged in.
Keep in mind that the az login command supports different authentication methods, and the device login flow is just one of them. Depending on your needs and environment, you might explore other authentication options, such as using a service principal or a managed identity.
If you want to see the subscriptions that are associated with your account, you can use the following command.
az account list --output table
This command will list the subscriptions and display their details in a table format.
We have successfully Azure CLI on ubuntu 22.04 LTS machine, If you still have questions, please post them in the comments section below.