Get started with Azure Command-Line Interface (CLI) (2024)

  • Article

Welcome to the Azure Command-Line Interface (CLI)! This article introduces the CLI and helps you complete common tasks.

Install or run in Azure Cloud Shell

The easiest way to learn how to use the Azure CLI is by running a Bash environment in Azure Cloud Shell through your browser. To learn about Cloud Shell, see Quickstart for Bash in Azure Cloud Shell.

When you're ready to install the Azure CLI, see the installation instructionsfor Windows, Linux, macOS, and Docker container. If you're using the Azure classic deployment model, install the Azure classic CLI.

Check your version by running az --version. Azure Cloud Shell always has the latest version of the Azure CLI preinstalled.

az version

Sign into the Azure CLI

Before using any Azure CLI commands with a local install, you need to sign in with az login.

  1. Run the az login command.

    az login

    If the Azure CLI can open your default browser, it initiates authorization code flow and opens the default browser to load an Azure sign-in page.

    Otherwise, it initiates the device code flow and instructs you to open a browser page at https://aka.ms/devicelogin. Then, enter the code displayed in your terminal.

    If no web browser is available or the web browser fails to open, you may force device code flow with az login --use-device-code.

  2. Sign in with your account credentials in the browser.

After logging in, you receive a list of subscriptions associated with your Azure account. Thesubscription information with isDefault: true is the currently activated subscription afterlogging in. To select another subscription, use the az account setcommand with the subscription ID of the desired account. For more information about subscription selection,see Manage Azure subscriptions.

There are ways to sign in non-interactively, which are covered in detail in Sign in with Azure CLI.

Find commands

Azure CLI commands are organized as command groups. Each group represents an area of an Azure service. There are two options to find command groups:

  • Use the az find command. For example, to search for command names containing vm, use the following command:

    az find vm
  • Use the --help argument to get a complete list of subgroups within a reference group. This example returns all the subgroups for virtual machines:

    az vm --help

    Here is example output with lines omitted for brevity:

    Subgroups: application : Manage applications for VM. availability-set : Group resources into availability sets. boot-diagnostics : Troubleshoot the startup of an Azure Virtual Machine. ...

    Here's another example that finds the Azure CLI commands for grouping virtual machines into availability sets, a subgroup of az vm:

    az vm availability-set --help

    Also use --help to get parameter lists and command examples for a reference command.

    az vm create --help

    Here is example output with lines omitted for brevity:

    Arguments --name [Required] : Name of the virtual machine. ...Authentication Arguments --admin-password : Password for the VM if authentication type is 'Password'. --admin-username : Username for the VM... ...Managed Service Identity Arguments ...Examples Create a VM from a custom managed image. az vm create -g MyResourceGroup -n MyVm --image MyImage ...
  • Use the A to Z reference index that lists all command groups alphabetically.

Find published samples and articles

If you prefer to learn Azure CLI syntax by seeing tested published examples, there are two indexes of article content:

  • Samples index A to Z. The samples index provides a list of Azure CLI samples sorted by subject area, reference group, and GitHub repository.

  • Article index A to Z. Use your keyboard find shortcut keys, likeCtrl + F, to drop quickly to the reference command group in which you're interested. For example, the article index looks something like this for az vm:

    Reference subgroupAzure CLI article showing reference use
    az vmOutput formats for Azure CLI commands
    How to use variables in Azure CLI commands
    Get VM information with queries
    {More articles listed here.}
    az vm aemNew Version of Azure VM extension for SAP solutions
    Standard Version of Azure VM extension for SAP solutions
    az vm application{...}

Use tab completion

The CLI has full tab completion for commands in a Bash environment. To enable tab completion in a PowerShell environment, see Enable tab completion in PowerShell.

Be aware of globally available arguments

There are some arguments that are available for most commands.

  • --help prints CLI reference information about commands and their arguments and lists available subgroups andcommands.

  • --output changes the output format. The available output formats are json, jsonc (colorized JSON), tsv (Tab-SeparatedValues), table (human-readable ASCII tables), and yaml. By default the CLI outputs json. To learn more about the availableoutput formats, see Output formats for Azure CLI.

  • --query uses the JMESPath query language to filter the output returned from Azure services. To learn more about queries, see Query command results with Azure CLI and the JMESPath tutorial.

  • --verbose prints information about resources created in Azure during an operation, and other useful information.

  • --debug prints even more information about CLI operations, used for debugging purposes. If you find a bug, provide output generated with the --debug flag on when submitting a bug report. It can be used, for example, to identify the REST API that the command executed is invoking underneath, and the response received from the service.

  • --subscription is the name or ID of a subscription. For more information about setting your default subscription, see Manage Azure subscriptions with the Azure CLI.

  • --only-show-errors suppresses warnings in command output and only shows errors.

Use interactive mode

The CLI offers an interactive mode that automatically displays help information and makes it easier toselect subcommands. You enter interactive mode with the az interactive command.

az interactive

For more information on interactive mode, see Run the Azure CLI in Interactive Mode.

There's also a Visual Studio Code plugin thatoffers an interactive experience, including autocomplete and mouse-over documentation.

Learn Azure CLI basics with quickstarts and tutorials

To learn how to use the Azure CLI, try our onboarding tutorial that teaches you the following skills while working with Azure Storage:

  • Find and change your default subscription.
  • Create an Azure resource containing a random ID in the name.
  • Set environment variables.
  • Learn syntax differences between Bash, PowerShell, and Cmd.
  • Debug Azure CLI reference commands.
  • Get properties from a local JSON file.. This example shows how to get configuration values for development, stage, and production.
  • Delete multiple resources using a script.

Note

In scripts and on the Microsoft documentation site, Azure CLI examples are written for theBash shell. Most one-line examples will run on any platform. Longer examples which include linecontinuations (\), variable assignment, or quotes need to be modified to work in other shells,including PowerShell. For more information on syntax differences between environments,see Learn syntax differences between Bash, PowerShell, and Cmd.

Give feedback

We welcome your feedback for the CLI to help us make improvements and resolve bugs. You can file an issue on GitHub or use the built-infeatures of the CLI to leave general feedback with the az feedback command.

az feedback

See also

  • Onboarding cheat sheet
  • Learn to use the Azure CLI tutorial
  • Use the Azure CLI in a Bash environment
  • Considerations for using the Azure CLI in a PowerShell environment
Get started with Azure Command-Line Interface (CLI) (2024)

FAQs

How to open Azure command line interface? ›

Windows
  1. Navigate to the official Azure CLI download page.
  2. Download the MSI file that's available for Windows.
  3. Run the MSI file and follow the installation wizard. ...
  4. Once installed, you can open the Command Prompt or PowerShell and type az to start using the Azure CLI.
Feb 16, 2024

How do I run Azure command-line? ›

Go to a VM in the Azure portal and select Run command from the left menu, under Operations. You see a list of the available commands to run on the VM. Choose a command to run. Some of the commands might have optional or required input parameters.

How do I start Azure VM from command-line? ›

If you don't have an Azure subscription, create a free account before you begin.
  1. Launch Azure Cloud Shell. ...
  2. Create a resource group. ...
  3. Create virtual machine. ...
  4. Install web server. ...
  5. Open port 80 for web traffic. ...
  6. View the web server in action. ...
  7. Clean up resources. ...
  8. Next steps.
Aug 22, 2024

Is there a CLI for Azure? ›

The Azure command-line interface (Azure CLI) is a set of commands used to create and manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation.

How do I access command line interface? ›

Windows
  1. Press the Windows key and “S”
  2. Type “cmd” into the search field.
  3. Right-click “Command Prompt” and select “Run as Administrator”
  4. You can now enter a command prompt.

How to login to az CLI? ›

Run the az login command. If the Azure CLI can open your default browser, it initiates authorization code flow and opens the default browser to load an Azure sign-in page. Otherwise, it initiates the device code flow and instructs you to open a browser page at https://aka.ms/devicelogin.

What is the difference between Azure PowerShell and Azure CLI? ›

Azure Powershell supports interactive scripting, deep integration with the Windows ecosystem, and outputs objects in PowerShell format. On the other hand, Azure CLI is a cross-platform tool that uses a shell scripting approach (bash, PowerShell) and outputs in various formats like JSON and tables.

How do I join Azure command line? ›

To locally verify that a device is enrolled in Azure AD:
  1. Log onto device.
  2. Open a command prompt (does not need to be as an administrator).
  3. Type the following command: dsregcmd /status.
  4. At the top of the output, the device should say "YES" for both Azure AD Joined and Domain Joined.
Jan 15, 2021

How to use Azure CLI commands in PowerShell? ›

If Azure Cloud Shell opens in a PowerShell scripting language, select the switch to Bash option in the Cloud Shell menu bar. A second instance of Azure Cloud Shell running with PowerShell. If Azure Cloud Shell opens in a Bash scripting language, select the switch to PowerShell option in the Cloud Shell menu bar.

Which Azure CLI command should you use? ›

Manage VM state
TaskAzure CLI commands
Start a VMaz vm start --resource-group myResourceGroup --name myVM
Stop a VMaz vm stop --resource-group myResourceGroup --name myVM
Deallocate a VMaz vm deallocate --resource-group myResourceGroup --name myVM
Restart a VMaz vm restart --resource-group myResourceGroup --name myVM
2 more rows
Aug 22, 2024

How to start a VM from CMD? ›

To power on a virtual machine from the command line:
  1. List the inventory ID of the virtual machine with the command: vim-cmd vmsvc/getallvms |grep <vm name> ...
  2. Check the power state of the virtual machine with the command: vim-cmd vmsvc/power.getstate <vmid>
  3. Power-on the virtual machine with the command:
Jul 18, 2024

How do I log into Azure VM using command line? ›

If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI. When you're prompted, install the Azure CLI extension on first use.

Is Azure CLI free or paid? ›

To use the CLI, you must have an Azure subscription. If you don't have an Azure subscription, create a free account before you begin.

Can Azure CLI run on Windows? ›

The Azure CLI is available to install in Windows, macOS and Linux environments. It can also be run in a Docker container and Azure Cloud Shell.

How do I use Azure CLI in local? ›

The Azure CLI for Windows can also be used from a browser through the Azure Cloud Shell or run from inside a Docker container. For Windows, the Azure CLI is installed via an MSI or a ZIP package, which gives you access to the CLI through the Windows Command Prompt (CMD) or PowerShell.

How do I log into Azure VM using command-line? ›

If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI. When you're prompted, install the Azure CLI extension on first use.

How do I join Azure command-line? ›

To locally verify that a device is enrolled in Azure AD:
  1. Log onto device.
  2. Open a command prompt (does not need to be as an administrator).
  3. Type the following command: dsregcmd /status.
  4. At the top of the output, the device should say "YES" for both Azure AD Joined and Domain Joined.
Jan 15, 2021

References

Top Articles
Celebrity Recipes - Ricky Lauren Cookbook
Easy Christmas Tarts: Delicious Recipe Ideas!
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Things to do in Wichita Falls on weekends 12-15 September
Craigslist Pets Huntsville Alabama
Paulette Goddard | American Actress, Modern Times, Charlie Chaplin
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
What's the Difference Between Halal and Haram Meat & Food?
Tyreek Hill admits some regrets but calls for officer who restrained him to be fired | CNN
Haverhill, MA Obituaries | Driscoll Funeral Home and Cremation Service
Rogers Breece Obituaries
Ems Isd Skyward Family Access
Elektrische Arbeit W (Kilowattstunden kWh Strompreis Berechnen Berechnung)
Omni Id Portal Waconia
Kellifans.com
Banned in NYC: Airbnb One Year Later
Four-Legged Friday: Meet Tuscaloosa's Adoptable All-Stars Cub & Pickle
Model Center Jasmin
Ice Dodo Unblocked 76
Is Slatt Offensive
Labcorp Locations Near Me
Storm Prediction Center Convective Outlook
Experience the Convenience of Po Box 790010 St Louis Mo
Fungal Symbiote Terraria
modelo julia - PLAYBOARD
Poker News Views Gossip
Abby's Caribbean Cafe
Joanna Gaines Reveals Who Bought the 'Fixer Upper' Lake House and Her Favorite Features of the Milestone Project
Tri-State Dog Racing Results
Navy Qrs Supervisor Answers
Trade Chart Dave Richard
Lincoln Financial Field Section 110
Free Stuff Craigslist Roanoke Va
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Ms. Lucile Johns

Last Updated:

Views: 5898

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Ms. Lucile Johns

Birthday: 1999-11-16

Address: Suite 237 56046 Walsh Coves, West Enid, VT 46557

Phone: +59115435987187

Job: Education Supervisor

Hobby: Genealogy, Stone skipping, Skydiving, Nordic skating, Couponing, Coloring, Gardening

Introduction: My name is Ms. Lucile Johns, I am a successful, friendly, friendly, homely, adventurous, handsome, delightful person who loves writing and wants to share my knowledge and understanding with you.