0
0
Azurecloud~5 mins

Azure CLI installation and login - Commands & Configuration

Choose your learning style9 modes available
Introduction
Azure CLI is a tool that helps you control Azure cloud services from your computer. Installing it and logging in lets you manage your cloud resources easily using commands.
When you want to create or manage Azure resources without using the web portal.
When you need to automate tasks like starting or stopping virtual machines.
When you want to check the status of your cloud services quickly from your terminal.
When you are setting up scripts to deploy applications to Azure.
When you want to learn Azure commands step-by-step on your local machine.
Commands
This command downloads and installs the Azure CLI on a Debian-based Linux system. It sets up the tool so you can use Azure commands.
Terminal
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Expected OutputExpected
Installing Azure CLI... Azure CLI installed successfully.
This command checks that Azure CLI installed correctly by showing its version and confirming it is ready to use.
Terminal
az --version
Expected OutputExpected
azure-cli 2.54.0 Python location '/usr/bin/python3' Extensions directory '/home/user/.azure/cliextensions' Python (Linux) 3.8.10 (default, Jun 4 2021, 15:09:15) [GCC 9.4.0] Legal docs and information: https://aka.ms/AzureCliLegal Your CLI is up-to-date.
This command opens a web page where you enter your Azure username and password to connect your CLI to your Azure account.
Terminal
az login
Expected OutputExpected
[ { "cloudName": "AzureCloud", "homeTenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "isDefault": true, "managedByTenants": [], "name": "My Azure Subscription", "state": "Enabled", "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "user": { "name": "user@example.com", "type": "user" } } ]
This command shows details about the Azure account you are logged into, confirming your login was successful.
Terminal
az account show
Expected OutputExpected
{ "environmentName": "AzureCloud", "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "isDefault": true, "name": "My Azure Subscription", "state": "Enabled", "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "user": { "name": "user@example.com", "type": "user" } }
Key Concept

If you remember nothing else from this pattern, remember: installing Azure CLI and logging in lets you control your Azure cloud resources easily from your computer.

Common Mistakes
Trying to run 'az login' before installing Azure CLI.
The 'az' command won't work because the tool is not installed yet.
First install Azure CLI using the installation command, then run 'az login'.
Not opening the web page to complete login after running 'az login'.
Without completing login in the browser, the CLI won't connect to your Azure account.
After running 'az login', open the provided URL in your browser and enter your credentials.
Running installation commands for a different operating system than the one you use.
Installation commands differ by OS; using the wrong one causes errors or no installation.
Use the installation command that matches your operating system (Linux, Windows, or macOS).
Summary
Install Azure CLI on your computer using the correct command for your OS.
Verify the installation by checking the Azure CLI version.
Log in to your Azure account using 'az login' and complete the browser authentication.
Confirm your login by running 'az account show' to see your subscription details.