Azure · · 2 min read

How to configure defaults for the Azure CLI

While using the Azure CLI I found it very frustrating to repeat information like the resource group name and other things over and over again. But luckily Microsoft took care of this

How to configure defaults for the Azure CLI

While using the Azure CLI I found it very frustrating to repeat information like the resource group name and other things over and over again. But luckily Microsoft took care of this...

Setting a default resource group

To set a default resource group, pass a key-value pair of group=<your resource group> to az configure --defaults and you can omit the --resource-group parameter to further calls.

az configure --defaults group=rs-mygroup

Setting a default location

This is similar to the resource group. Just use the location=<your prefered location> key-value pair.

az configure --defaults location=switzerlandnorth

To see all possible locations enter the following:

az account list-locations

Setting the default output format to table

To configure the default output format, use the interactive az configure command to set up your environment and establish default settings for output formats. The default output format is json.

az configure

Then later, choose your desired default...

Welcome to the Azure CLI! This command will guide you through logging in and setting some default values.

Your settings can be found at /home/defaultuser/.azure/config
Your current configuration is as follows:

  ...

Do you wish to change your settings? (y/N): y

What default output format would you like?
 [1] json - JSON formatted output that most closely matches API responses.
 [2] jsonc - Colored JSON formatted output that most closely matches API responses.
 [3] table - Human-readable output format.
 [4] tsv - Tab- and Newline-delimited. Great for GREP, AWK, etc.
 [5] yaml - YAML formatted output. An alternative to JSON. Great for configuration files.
 [6] none - No output, except for errors and warnings.
Please enter a choice [1]:

Happy hacking!

Further reading

Azure CLI configuration options
The Azure CLI allows user configuration for various settings. Manage values with the az configure command, environment variables, or in the configuration file.

Read next