Azure architectureBeginner27 min read

What Does Azure CLI Mean?

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security
On This Page

Quick Definition

Azure CLI is a tool you use to control Microsoft Azure from a command prompt or terminal. Instead of clicking buttons in a web browser, you type commands to create, update, or delete cloud resources like virtual machines or databases. It works on Windows, macOS, and Linux and can be automated in scripts.

Common Commands & Configuration

az login --use-device-code

Logs in to Azure using a device code flow, allowing authentication without a direct browser on the current machine.

Tests understanding of authentication methods for headless or automated scenarios; often appears in questions about service principals vs interactive login.

az group create --location eastus --name myResourceGroup

Creates a new resource group in the East US region with the specified name.

Fundamental command for resource organization; exams test knowledge of resource group location requirement and naming conventions.

az vm create --resource-group myResourceGroup --name myVM --image Ubuntu2204 --generate-ssh-keys

Creates a Linux VM with auto-generated SSH keys in the specified resource group.

Commonly appears in lab scenarios and exam questions about VM deployment, SSH key management, and the --generate-ssh-keys flag.

az storage account list --query "[].name" --output tsv

Lists all storage account names in the current subscription in tab-separated format.

Tests knowledge of --query and --output options; exams ask how to filter or format results for scripting.

az role assignment create --assignee user@domain.com --role Contributor --scope /subscriptions/{sub-id}/resourceGroups/myRG

Assigns the Contributor role to a user at the resource group scope.

Critical for RBAC questions; exams test scoping (subscription, resource group, resource) and role assignment syntax.

az acr build --registry myRegistry --image myimage:latest .

Builds and pushes a container image to Azure Container Registry from the current directory context.

Tests understanding of ACR tasks; exams often ask about image tagging, registry login, and building from source.

az webapp log tail --name myApp --resource-group myRG

Streams live logs from an App Service web app to the console.

Used for troubleshooting deployments; exam questions focus on log streaming during failed deployments or configuration issues.

Azure CLI appears directly in 78exam-style practice questions in Courseiva's question bank — one of the most-tested concepts on AZ-104. Practise them →

Must Know for Exams

Azure CLI appears directly in several certification exams, particularly those focused on Azure administration and development. For the AZ-104 (Microsoft Azure Administrator) exam, you are expected to understand how to install Azure CLI, authenticate, and execute commands to manage resources like virtual machines, storage accounts, and virtual networks. The exam objectives explicitly mention using Azure CLI for tasks such as deploying resources, configuring networking, and managing identities. You will see scenario-based questions where you must determine the correct Azure CLI command to create a resource or apply a policy. For example, a question might ask, “You need to create a storage account named ‘prodstorage’ in the resource group ‘prod-rg’ in the East US region. Which Azure CLI command should you run?” The answer would be something like “az storage account create --name prodstorage --resource-group prod-rg --location eastus.”

For the AZ-900 (Azure Fundamentals) exam, the questions are more conceptual. You will not need to memorize specific CLI commands, but you must understand what Azure CLI is and when it is used. You might get a multiple-choice question like, “Which tool would you use to automate the creation of multiple Azure resources from a script?” The answer would be Azure CLI. Similarly, you should know that it is cross-platform and can be used in the Azure Cloud Shell. The exam may also ask about the difference between Azure CLI and Azure PowerShell, so being clear on those distinctions is important.

In the AWS-related exams mentioned (aws-cloud-practitioner, aws-developer-associate, aws-saa), Azure CLI is not directly tested, but the concept of a command-line tool for cloud management is transferable. You may encounter comparative questions that ask about similar tools in AWS, like the AWS CLI. The course may include a question that tests your understanding of what a CLI is in general. For Google Cloud exams (google-ace, google-cloud-digital-leader), the equivalent is the gcloud CLI. Answering a question about Azure CLI correctly shows that you understand the pattern of cloud management tools. It is important to remember that Azure CLI is specific to Azure; it cannot manage AWS or Google Cloud resources. Exam questions sometimes try to confuse you by suggesting that Azure CLI can manage multi-cloud environments. It does not.

Overall, in exams, Azure CLI questions are either direct (asking for a specific command) or conceptual (asking about its purpose and capabilities). The key to doing well is to practice the commands yourself. Even if you only use the Azure Cloud Shell in a browser, typing a few commands will help you remember the syntax. Focus on the common verbs: create, show, list, delete, update. Know how to use “az group create” for resource groups and “az vm create” for virtual machines. Also, understand that the CLI returns JSON by default, but you can change the output format with the “--output” parameter. Being comfortable with these basics will serve you well on the exam and in real life.

Simple Meaning

Imagine you are the manager of a large apartment complex. You have a maintenance office with a computer that has two ways to get things done. One way is to walk around the complex, look at the building, and use a tablet to tap on buttons to fix a leaky pipe or turn on lights. That is like using the Azure Portal, where you click through menus and screens. The other way is to have a walkie-talkie and give direct, short orders to your team: “Turn on the water pump in Building A,” “Lock the maintenance door,” or “Add a new parking spot for Unit 5.” That is what Azure CLI is like. It is a text-based way to give commands to Azure directly.

Instead of using a mouse, you open a command-line interface-like PowerShell on Windows, Bash on Linux, or a terminal on Mac-and you type something like “az vm create” followed by the name of the virtual machine you want. Within seconds, Azure does exactly what you asked. This is very helpful when you need to do the same task many times, like setting up ten servers that are identical. You could write a script that repeats the command ten times, and it would be done in a minute, while clicking through the portal would take much longer and be more likely to cause errors.

Azure CLI speaks the same language as the Azure Portal behind the scenes. Both use the same API-think of it as the same set of instructions that Azure understands. When you type a command, Azure CLI translates it into an API call and sends it to Azure servers, which then perform the task. The tool is free and can be installed on your computer or run directly from the Azure Cloud Shell in a web browser. For beginners, it might feel intimidating because you have to remember commands, but it is actually simpler for repetitive tasks because you can copy, paste, and reuse commands without worrying about forgetting a step. Many IT professionals prefer it because it is fast, consistent, and can be automated, which saves time and reduces human error.

Full Technical Definition

Azure CLI, officially named the Azure Command-Line Interface, is a cross-platform command-line tool provided by Microsoft for managing Azure resources. It is built on top of the Azure REST API and uses Python and the Azure SDK for Python to translate user commands into HTTP requests to Azure’s underlying infrastructure. When a user runs a command such as “az group create” to create a resource group, the CLI authenticates via Azure Active Directory (Azure AD) using OAuth 2.0 flows, then constructs a REST API call to the Azure Resource Manager (ARM) endpoint, typically https://management.azure.com. The response is returned in JSON format, which the CLI then formats for human-readable output.

The tool supports multiple output formats, including JSON, table, TSV, and YAML, allowing integration with other tools and scripts. It is designed to work with Azure Resource Manager, the modern deployment and management service for Azure. Azure CLI interacts with all resource providers, such as Microsoft.Compute for virtual machines, Microsoft.Storage for storage accounts, and Microsoft.Network for virtual networks. Each command follows a consistent naming pattern: a base command like “az vm” followed by a verb like “create,” “show,” “list,” or “delete.” This verb-noun convention makes it predictable and script-friendly.

Azure CLI can be installed locally via an MSI package on Windows, apt-get on Ubuntu, yum on RHEL, or Homebrew on macOS. It can also be used through the Azure Cloud Shell, which is an in-browser shell that comes pre-authenticated and pre-installed with common tools. The CLI supports advanced features like JMESPath queries for filtering output, role-based access control (RBAC) integration, and Azure Policy enforcement. For automation, Azure CLI commands can be incorporated into Bash, PowerShell, or Python scripts, and they can be run in CI/CD pipelines such as Azure DevOps or GitHub Actions. Error handling is built-in: the CLI returns non-zero exit codes on failure, making it suitable for reliable scripting. Command output can be piped to other commands, enabling complex workflows like creating a virtual network and then immediately deploying a virtual machine into it using a single script. Azure CLI is updated regularly, with new commands and improvements released monthly, and it is under active development as an open-source tool on GitHub.

From a networking perspective, the CLI communicates over HTTPS (port 443) and uses TLS 1.2+ encryption. Authentication methods include interactive login, service principal with certificate or client secret, managed identity, and device code flow for headless environments. The CLI stores tokens and configuration locally in a hidden folder, usually ~/.azure on Linux/macOS or %USERPROFILE%\.azure on Windows. It can also be used with Azure CLI extensions to add support for newer services like Azure Container Apps or Azure Arc without requiring a full tool update. For exam purposes, you should understand that Azure CLI is not a graphical tool; it is entirely text-driven and is ideal for scripting and automation. It can be run in batch mode, and multiple commands can be combined into a single script file. The CLI also supports resource ID parameters, allowing you to reference existing resources directly without needing to specify their name and resource group separately. Overall, Azure CLI is a powerful, lightweight, and flexible tool that is essential for any Azure administrator or developer who needs to manage cloud resources programmatically.

Real-Life Example

Think of a busy restaurant kitchen. The head chef has two ways to tell the kitchen staff what to do. One way is to walk to each workstation and point at ingredients, write on a whiteboard, and talk to each cook individually. That is like using the Azure Portal-clicking around, opening menus, and filling out forms. The other way is for the head chef to stand at a central station and shout out orders: “Fire table 5’s salmon! Start the grill for table 7! Prepare the dessert for table 3!” Those are short, clear commands that the line cooks instantly understand and execute. That is exactly how Azure CLI works.

In the kitchen, each command is direct and leaves no room for confusion. The chef does not need to walk to each station; they just call out the order, and the cooks respond. Similarly, with Azure CLI, you type a command like “az vm start --name MyVM --resource-group MyGroup,” and Azure immediately starts that virtual machine. The chef can call out multiple orders in rapid succession, and the kitchen handles them in order. Likewise, you can run a series of Azure CLI commands in a script to create a network, deploy a server, and open a firewall port, one after the other, without any delay.

Also, think about a busy Saturday night when the same orders come in repeatedly. The chef could write down a set of instructions for a popular dish and hand it to a junior cook. That is like creating an Azure CLI script. You can write all the commands for setting up a new website, save them in a text file, and run the whole file whenever you need to deploy that site again. You do not have to remember each step or worry about missing a detail because the script is consistent and automated. Just like a recipe ensures the dish comes out the same every time, an Azure CLI script ensures your cloud resources are built exactly the same way every time.

But there is a catch. If the chef shouts a command incorrectly, the wrong dish might be cooked. Similarly, if you mistype an Azure CLI command or use the wrong parameter, you could create an expensive resource by accident or delete something critical. That is why it is important to double-check commands, especially before running commands that delete or modify existing resources. Azure CLI provides a “--dry-run” or “--what-if” option for some commands to preview changes without actually making them. In the kitchen, the chef might have a sous-chef confirm the order before it is sent out-that is your validation step.

Overall, Azure CLI is like a loud, clear voice in a busy kitchen. It is efficient, repeatable, and powerful, but it requires you to know the correct words and phrases to say. Once you learn them, you can manage your entire cloud environment faster and more reliably than clicking through a web browser.

Why This Term Matters

Azure CLI matters because it directly impacts how IT professionals manage Azure resources in real-world environments. In a typical IT job, you will not always have the luxury of opening a web browser and clicking through the Azure Portal. Many tasks need to be automated, scheduled, or run as part of a larger workflow. For example, a system administrator might need to spin up 50 virtual machines for a load test at 2 AM. Doing that manually through the portal would be impractical and error-prone. With Azure CLI, you can write a short script that loops 50 times and creates the VMs automatically. This saves hours and reduces the chance of a typo or missed configuration.

Another reason it matters is consistency. When multiple team members manage the same Azure subscription, the portal can lead to configuration drift-one person might click a different option or forget a setting. Azure CLI scripts, when stored in source control like Git, provide a single source of truth. Everyone runs the same commands, so the environment is reproducible. This is a core principle of Infrastructure as Code (IaC), which is a best practice in modern cloud management. Azure CLI is often the first tool that professionals use before moving to more advanced IaC tools like Terraform or ARM templates.

Finally, Azure CLI is a requirement for many Azure certification exams, especially AZ-104 (Azure Administrator) and AZ-900 (Azure Fundamentals). You will be tested on how to use it, what commands to run, and how to interpret output. Knowing Azure CLI not only helps you pass exams but also builds a skill you will use daily in your job. It is a foundational tool that is lightweight, free, and available everywhere. For IT professionals, not knowing how to use the command line is like a mechanic not knowing how to use a wrench. It is that essential.

How It Appears in Exam Questions

Azure CLI questions in certification exams generally fall into three patterns: scenario-based, configuration-based, and troubleshooting. In a scenario-based question, you are given a business requirement and asked to choose the correct command or set of commands. For example, a question might read: “Your company needs to deploy a new web server in the West US region. The resource group ‘web-rg’ already exists. You need to create a Linux virtual machine named ‘web-vm’ with a size of Standard_D2s_v3. Which Azure CLI command should you use?” The correct answer would be “az vm create --resource-group web-rg --name web-vm --image UbuntuLTS --size Standard_D2s_v3 --location westus.” You need to know the correct parameters and syntax.

Configuration-based questions ask you to determine the effect of a command or to identify a missing parameter. For instance, “You run the command ‘az storage account create --name mystorage --resource-group myrg --location eastus --sku Standard_LRS.’ What is the result?” You need to understand that this command creates a storage account with locally redundant storage. The question may also ask about output: “You run ‘az vm list --output table.’ What does the output show?” You should know that it returns a table of virtual machines with columns like Name, ResourceGroup, Location, and Status.

Troubleshooting questions present a problem and ask for the Azure CLI command to diagnose it. For example, “A virtual machine named ‘app-vm’ is not responding. You need to check its status and recent activities. Which Azure CLI command would you run first?” The answer might be “az vm show --name app-vm --resource-group app-rg” to view its current state, followed by “az monitor activity-log list --resource-group app-rg.” Another common pattern involves authentication: “You are unable to run Azure CLI commands because you are not logged in. What command should you run first?” The answer is “az login.”

Multiple-choice questions might ask about the nature of Azure CLI itself, such as: “Which of the following is true about Azure CLI?” with options like “It is only available on Windows,” “It can manage multiple cloud providers,” “It uses REST APIs to interact with Azure,” or “It requires a graphical interface.” The correct answer is that it uses REST APIs. Some questions will present a command with a deliberate error, like using a flag incorrectly (e.g., “--location” vs “--region”) and ask you to identify the issue. Common traps include using Azure PowerShell syntax in a CLI question or confusing resource group and location order. Always double-check the verb and parameter names because the exam expects exact Azure CLI syntax.

Practise Azure CLI Questions

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You work for a small company that wants to set up a simple website to show their company portfolio. The website will run on a Linux virtual machine in Azure. Your manager asks you to create the virtual machine as quickly as possible and make sure it is set up correctly. You have already created a resource group named “CompanyWeb” in the East US region. Now you need to create the VM itself.

You open Azure Cloud Shell, which is a command-line environment in your web browser that already has Azure CLI installed and logged in. You type the following command:

az vm create --resource-group CompanyWeb --name PortfolioVM --image UbuntuLTS --admin-username azureuser --admin-password P@ssw0rd1234

(Note: In a real scenario, you should use SSH keys, not a password, but for this example, we use a password for simplicity.)

After pressing Enter, the Azure CLI sends this command to Azure. The Azure Resource Manager checks that your resource group exists and that you have permission to create a VM. It then starts the creation process. The CLI shows a JSON output with details about the VM, including its public IP address, private IP address, and the status of the provisioning. Once the command finishes, you can connect to the VM using SSH with the public IP address and the username you specified.

Now imagine you need to create similar VMs for other departments. You could type the same command again and again, but that is slow. Instead, you could write a script that loops through a list of department names and creates a VM for each one. That would save you a lot of time. This scenario shows how Azure CLI lets you create cloud resources quickly and consistently with just one line of text, making it ideal for both one-time tasks and automation.

Common Mistakes

Confusing Azure CLI commands with Azure PowerShell syntax.

Azure CLI uses “az” as its base command, while Azure PowerShell uses cmdlets like “New-AzVm.” Mixing these up will result in errors because the command syntax is completely different.

Always remember that Azure CLI commands start with “az.” If you are unsure, use “az --help” to list available commands.

Forgetting to specify the resource group in commands that require it.

Many Azure CLI commands like “az vm create” require the “--resource-group” parameter. Without it, the command will fail or create resources in a default context, which can cause confusion.

Always include “--resource-group” in commands that create or modify resources. Check the command’s help with “az <command> --help” if you are unsure.

Using wrong region names that do not exist or are misspelled.

Azure has specific region names like “eastus” (one word) and “westus2.” Using “East US” (with a space) will cause an error because the CLI expects a single, lowercase string without spaces.

Use “az account list-locations --output table” to see valid region names. Copy them exactly as shown.

Not authenticating before running commands.

If you are not logged in, running a command like “az vm list” will return an authentication error. Users sometimes forget to run “az login” first.

Always run “az login” when you open a new terminal session. In Azure Cloud Shell, you are automatically authenticated.

Assuming Azure CLI can manage AWS or Google Cloud resources.

Azure CLI is designed exclusively for Microsoft Azure. It cannot manage resources from other cloud providers. Trying to do so will fail or produce irrelevant results.

Remember that each cloud provider has its own CLI tool: AWS CLI for AWS, gcloud for Google Cloud, and Azure CLI for Azure.

Deleting a resource without confirming or using the wrong resource name.

Commands like “az group delete” do not always ask for confirmation. If you accidentally delete the wrong resource group, you can lose all resources inside it permanently.

Use “az group delete --name MyGroup --no-wait” only when sure. Use “az group list” to verify the name first. Consider using the “--what-if” flag if supported.

Using the wrong output format and being unable to parse the result.

The default output for Azure CLI is JSON. If you expect a simple table but get nested JSON, you might misread the data or fail to use it in a script.

Use “--output table” for human-readable tables, or “--output yaml” for scripts. Use “--query” with JMESPath to filter specific values.

Exam Trap — Don't Get Fooled

{"trap":"A question asks which command line tool you should use to manage Azure resources from a Linux machine. Options include “Azure PowerShell,” “Azure CLI,” “Azure Portal,” and “Azure SDK.” The trap is that Azure PowerShell is available on Linux, but Azure CLI is the most straightforward and common answer."

,"why_learners_choose_it":"Learners might choose Azure PowerShell because they have used it on Windows and assume it is the only option. Or they might think Azure Portal is command-line because it runs in a browser.","how_to_avoid_it":"Remember that Azure CLI is the primary cross-platform command-line tool for Azure.

It works natively on Linux, macOS, and Windows. Azure PowerShell is also cross-platform (since PowerShell Core), but the exam expects Azure CLI as the command-line interface for managing Azure. When in doubt, choose the one with “CLI” in its name."

Commonly Confused With

Azure CLIvsAzure PowerShell

Azure PowerShell uses PowerShell cmdlets (e.g., New-AzVm) that are object-oriented, while Azure CLI uses simpler text commands (e.g., az vm create). Azure CLI is generally more straightforward for quick tasks, while Azure PowerShell is more powerful for complex scripting in the PowerShell environment.

To create a VM in Azure CLI: “az vm create --name MyVM ...”. In Azure PowerShell: “New-AzVm -Name MyVM ...”

Azure CLIvsAzure Portal

Azure Portal is a graphical web interface where you click buttons and fill forms. Azure CLI is a text-only interface where you type commands. The Portal is great for beginners and for exploring, while CLI is best for automation and repetitive tasks.

To create a resource group in the Portal, you navigate to “Resource groups”, click “Create,” fill the form, and click “Review + create.” In CLI, you just type “az group create --name MyGroup --location eastus.”

Azure CLIvsAzure SDK

The Azure SDK is a set of libraries for programming languages like Python, .NET, and Java, used to write code that interacts with Azure services. Azure CLI is a standalone tool that uses the SDK internally but is meant for direct command-line use. You do not need to write code to use Azure CLI.

Using Azure SDK in Python: you write a script that imports “azure-mgmt-compute” and calls functions. Using CLI: you just run “az vm list.”

Azure CLIvsAWS CLI

AWS CLI is the equivalent tool for Amazon Web Services. It uses a different command syntax (e.g., “aws ec2 run-instances”) and manages AWS resources, not Azure resources. Azure CLI cannot manage AWS, and AWS CLI cannot manage Azure.

To list S3 buckets in AWS CLI: “aws s3 ls.” To list Azure storage accounts: “az storage account list.”

Azure CLIvsgcloud CLI

gcloud CLI is the command-line tool for Google Cloud Platform. It uses commands like “gcloud compute instances create.” Like AWS CLI, it is specific to Google Cloud and is not interchangeable with Azure CLI.

To create a Compute Engine VM: “gcloud compute instances create my-vm.” To create an Azure VM: “az vm create --name my-vm.”

Step-by-Step Breakdown

1

Install or Access Azure CLI

You can install Azure CLI on your local machine using the appropriate package manager for your OS, or you can use Azure Cloud Shell, a browser-based shell that comes pre-installed with Azure CLI and is automatically authenticated. This step ensures the tool is available.

2

Authenticate to Azure

Run “az login” to open a browser or device login flow. This authenticates you with your Azure account and obtains an OAuth 2.0 token. The token is cached locally so subsequent commands do not require re-authentication.

3

Set the Active Subscription

If you have multiple Azure subscriptions, run “az account set --subscription <id>” to select the one you want to manage. All commands will then apply to this subscription. This prevents you from accidentally modifying resources in the wrong subscription.

4

Create a Resource Group

A resource group is a logical container for Azure resources. Run “az group create --name MyResourceGroup --location eastus” to create one. This organizes your resources and makes management easier.

5

Create a Virtual Network

Run “az network vnet create --name MyVNet --resource-group MyResourceGroup --address-prefix 10.0.0.0/16” to create a virtual network. This provides a private network for your VMs and other resources.

6

Create a Virtual Machine

Run “az vm create --name MyVM --resource-group MyResourceGroup --image UbuntuLTS --admin-username azureuser --generate-ssh-keys” to create a Linux VM. This command automatically creates the necessary public IP, network interface, and OS disk.

7

Verify the Resource

Run “az vm show --name MyVM --resource-group MyResourceGroup --output table” to view details of the VM. This confirms the resource was created successfully and shows its status, IP addresses, and other properties.

8

Clean Up Resources

To avoid ongoing costs, run “az group delete --name MyResourceGroup --yes --no-wait” to delete the entire resource group and all resources inside it. The “--yes” flag skips the confirmation prompt, and “--no-wait” returns immediately without waiting for the operation to complete.

Practical Mini-Lesson

Azure CLI is a powerful tool, but it requires a careful approach to avoid mistakes and maximize efficiency. Let us walk through a practical lesson. First, always work in a test environment or use a non-production subscription when learning. One way to do this is to create a separate resource group specifically for experimentation. This way, if something goes wrong, you can delete the entire resource group without affecting production resources.

When you are writing scripts, use the “--output json” parameter and pipe it to “query” with JMESPath to extract specific values. For example, to get the public IP address of a VM, you can run: “az vm show --name MyVM --resource-group MyRG --query ‘{ip:publicIps}’ --output tsv”. This returns only the IP address, which you can then assign to a variable in a script. This is much more efficient than parsing the entire JSON output manually.

Another practical tip is to use Azure CLI in combination with tools like jq (a JSON processor) or PowerShell for advanced parsing. However, for exam purposes, focus on the basic commands and the “--query” parameter. Also, understand that Azure CLI commands can be idempotent-running the same command multiple times may produce different results if the resource already exists. For example, running “az vm create” again with the same name will fail because the VM already exists. But running “az group create” multiple times with the same name will succeed and return the existing resource group.

What can go wrong? Common issues include authentication timeouts (re-login with “az login”), network connectivity problems, or command syntax errors. Azure CLI provides detailed error messages. Look for the “ErrorDetails” section in the output, which often contains the specific HTTP status code and message from the Azure API. For example, a 403 error means you lack permissions, while a 404 error means the resource was not found. Learning to read these errors will save you a lot of time.

For professionals, Azure CLI is often used in CI/CD pipelines. In Azure DevOps, you can add a “Azure CLI” task to a pipeline that runs commands stored in a script file. The pipeline runs these commands every time you push code, ensuring your infrastructure stays up-to-date. Similarly, in GitHub Actions, you can use the “Azure CLI” action to run commands. This is a key reason why Azure CLI is so important-it enables Infrastructure as Code, which is a modern best practice.

Finally, remember that Azure CLI extensions allow you to manage services that are not yet part of the core CLI. For example, the Azure IoT extension adds commands for managing IoT hubs. You can add extensions by running “az extension add --name azure-iot.” This keeps the base CLI lightweight while giving you the flexibility to add functionality as needed.

Troubleshooting Clues

Azure CLI fails with 'No subscription found'

Symptom: Running any command returns error: 'Please run az login' or 'No subscriptions found' after login

User may be logged into a tenant where they have no Azure subscriptions, or default subscription is not set; az account set must be used to select an active subscription

Exam clue: Exams test the need to set a default subscription after login when multiple tenants or subscriptions exist.

Azure CLI hangs during 'az login' with browser

Symptom: Command 'az login' opens browser but never completes or times out

Often due to browser not accepting redirect URIs, or firewall blocking localhost callbacks; using --use-device-code bypasses browser dependency

Exam clue: Appears in questions about authentication failures in restricted environments; device code flow is the alternative.

Role assignment fails with 'PrincipalNotFound'

Symptom: Running az role assignment create returns error: 'The specified principal... does not exist'

The user, group, or service principal object ID is incorrect or not found in the same tenant; --assignee must match exact object ID or UPN

Exam clue: Exams test that service principal IDs must be from the same directory and often include distractor UPNs.

'az deployment group create' fails with 'InvalidTemplate'

Symptom: Deployment fails with 'Deployment template validation failed'

Template JSON has syntax errors, missing parameters, or references to non-existent resources; often due to incorrect parameter file or expressions

Exam clue: Questions about ARM template debug: use --what-if parameter to test changes before deployment.

Azure CLI command times out when creating large VM

Symptom: Command runs for over 10 minutes and then returns timeout error

Default timeout might be too short; use --no-wait to deploy asynchronously and then check status with az vm show

Exam clue: Tests understanding of long-running operations and --no-wait flag for automation.

Storage account commands fail with 'AuthorizationFailed'

Symptom: User has 'Reader' role but cannot list storage account keys

Reader role does not include Microsoft.Storage/storageAccounts/listkeys/action; requires 'Storage Account Key Operator' or Contributor role

Exam clue: Exams test role permissions for storage operations; listkeys requires specific action.

Az CLI shows 'WARNING: Authorization failed' after login change

Symptom: Commands that worked earlier start failing after switching accounts or subscriptions

Cached tokens may be stale or permissions changed; run az logout then az login to refresh token cache

Exam clue: Common scenario in exams where token expiry causes access denial; force relogin is the fix.

JSON output is truncated in terminal

Symptom: Az CLI output with --output json shows ellipsis (...) especially for resource lists

Terminal width is limited; use --output table or pipe to jq; alternatively set default output in config

Exam clue: Questions about formatting Azure CLI output for readability; table format is best for humans.

Memory Tip

Remember “az” is the base command-like the az in Azure. When you see “az,” think “Azure commands.” The pattern is always “az <service> <verb> --parameters.”

Learn This Topic Fully

This glossary page explains what Azure CLI means. For a complete lesson with labs and practice, see the topic guide.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Related Glossary Terms

Quick Knowledge Check

1.Which Az CLI command is used to deploy an ARM template to a resource group?

2.A user needs to manage Azure resources from a CI/CD pipeline without interactive login. Which authentication method is most appropriate?

3.What does the --query parameter do in Az CLI?

4.Which role must be assigned to allow a user to list storage account keys via Az CLI?

5.After logging in with az login, a user gets 'No subscriptions found'. What is the most likely fix?