Azure CLI Commands Help
Explore the core Azure CLI commands to create and manage resources, use interactive mode for command assistance, and format outputs using JSON, YAML, or tables. Understand how to use command chaining, asynchronous execution, and persist configuration parameters for efficient Azure management.
We'll cover the following...
CLI scope
Azure CLI offers a vast number of commands for the execution of various services. The key services include the following:
- AI and ML
- Analytics
- Blockchain
- Computing and containers
- Databases and storage
- DevOps and developer tools
- IoT
- Media
- Mobile
- Networking and security
- Web
To learn the usage of a specific command, we use the command below:
We can also run the CLI in the interactive mode using the az interactive command.
Run the terminal below to figure out what the find command does.
Also, let’s explore the az group command more, which helps us create a resource group (more on this later).
To run the CLI in interactive mode, use the following command:
We can get interactive support for commands (similar to autosuggest or spell corrections).
Let’s try the interactive mode launched by the terminal below. Type any command, like az account or az group, and it will show the interactive help.
Now, let’s learn more about the standard and important command groups for Azure CLI. We can create, delete, and manage groups using the commands associated with each command group.
Azure Command Groups
Commands Groups | Description |
| Create, delete, and manage resource groups and template deployments |
| Manage Azure CLI configurations |
| Manage Azure capacity |
| Manage Azure Cognitive Services accounts |
| Manage Azure Data Factory |
| Manage Azure Resource Manager template deployment |
| Create and manage rollouts and deployments for the service |
| Manage Azure Machine Learning resources with the extension (preview) |
| Manage Azure Pipelines |
| Manage Azure resources (keyvault, storage, etc.) |
| Manage Azure Cloud Storage resources (Blob storage, table storage, storage accounts, etc.) |
| Manage Linux or Windows VMs |
Command-line arguments and explanations
--help: Prints out CLI command help.--output: Changes the output format (tsv,json,yaml, and so on).--query: Returns filtered output using a query, as seen below:
The above command prints all the accounts in the 'eastus' region associated with the account.
--verbose: Prints more information about command execution, including created resources.--debug: Prints more debugging information.
CLI can generate output in different formats.
-
json: JSON string. This is the default setting. -
jsonc: Colorized JSON. -
yaml: YAML is a human-readable alternative to JSON. -
yamlc: Colorized YAML. -
table: ASCII table with keys as column headings. -
tsv: Tab-separated values with no keys. -
none: No output other than errors and warnings.
Let’s learn with examples. Consider the command below, which displays all the subscriptions registered with the Microsoft account.
The above command generates an output in the following manner; the tenant ID in the output is masked here:
Now, we want the output to be generated in the YAML format. We will add the output parameter with the YAML specification.
The command output will be printed in the YAML schema, as shown below:
Miscellaneous features
- The output of one command can be passed as an input to the other.
The following example assigns an ID found by the
az vm listcommand to a variable.
- Asynchronous commands:
Many commands offer a
--no-waitparameter, which allows other commands to run. The following example creates a VM. Since it’s a long-running command, the user gets unblocked to execute other commands.
- Persisted commands: Use persisted commands to save the command-line arguments. Most of the Azure commands require configuration parameters like resource group and workspace. Instead of repeatedly using the same values, we can persist them for a session.
When we create the resource group, the values persist. When we print the persisted values, we can observe the output like this:
This way, we can keep referring to the stored values.