The Azure CLI is a cross-platform, command-line tool built-in Python that creates, updates, and removes nearly all Azure resources.
This shot is meant to be a brief overview of the Azure CLI. If you’d like to learn more about this topic, check out the
. Microsoft documentation https://learn.microsoft.com/en-us/cli/azure/get-started-with-azure-cli?view=azure-cli-latest
To be used on the Cloud Shell, it comes pre-installed.
However, for local installations, check out
to install it. It would help if you authenticated the Azure CLI using the command these instructions https://learn.microsoft.com/en-us/cli/azure/install-azure-cli az login
, and set the default subscription usingaz account set
.
Run the following command to set the default subscription, changing the [subscription name]
placeholder with the name of your subscription.
az account set --subscription '[subscription name]'
The Azure CLI is built around the premise of commands. The Azure CLI all stems from a single command called az
, which kicks off the Azure CLI.
Command groups are sets of commands all related to a particular Azure service.
For example, to manage subscriptions, you’d use the account command group. To manage
Every Azure CLI command group and command has a universal --help
argument, which shows all the options related to that command or group.
For example, at the root level, the following command returns all of the available groups and subgroups for the az
command:
az --help
You can now drill down into any of the subgroups to explore more. Let’s say that you’d like to manage resource groups. Scrolling down a bit, you’ll see a subgroup called group
. Provide that group
as an argument to az
with --help
and see what happens. The command will be:
az group --help
We have the az find
command to discover examples of using various commands and command groups.
The following command shows you the examples related to the storage account:
az find "az storage"
For example, the first command gives examples related to groups and the second command specifically provides examples related to group creation:
az find "az group"
az find "az group create"
In this mode, you can begin typing groups and subgroups and be automatically prompted for required parameters. In the following screenshot, simply typing group create
brought up available arguments and examples.
Interactive mode is like using --help
and az find
all at once as you type.
If you’d like to learn more about the interactive mode, check out the
Using extensions, you can add on additional groups and commands if they don’t come pre-installed.
You can check all available extensions within the Azure CLI using the az extension list-available
command. Try the following command:
az extension list-available --output table
The Azure CLI has a common set of arguments that are available on all commands; the
---output
argument is one. You can learn about the other common arguments by visiting the. Microsoft documentation https://learn.microsoft.com/en-us/cli/azure/get-started-with-azure-cli?view=azure-cli-latest
Once you’ve found an extension, use the az extension add
command to download and install it.
az extension add --name <extension-name>
You can update the extension to the latest version by using the az extension update
command.
az extension update --name <extension-name>
Finally, you can also uninstall it using az extension remove
.
az extension remove --name <extension-name>
Free Resources