Reading Time: 2 minutes

Although I mainly use PowerShell for my scripting needs, I sometimes really enjoy the lack of “chattiness” in Az CLI and that is why I like to keep it updated at all times. Let’s see how we can achieve that automatically as well as manually.

Note: the ways of an upgrade as shown in this blog were introduced in Az CLI version 2.11 and will only work with that version or later. To check your version of the azure-cli issue az version.
If you don’t have the azure-cli installed or is an old version, you can check your installation options here in the Microsoft Docs | Install the Azure CLI.

Az CLI manual upgrade

Apart from the various package managers, the CLI provides an in-tool command to perform an upgrade to the latest version by issuing the below command:

#Azure CLI
az upgrade

az upgrade is supported on Windows, macOS, and some Linux distros and it only brings you to the latest version of the CLI. This will also upgrade all installed extensions. If you want to disable that default behavior, read on.

Az CLI automatic upgrade

By default the auto-upgrade feature is disabled. You can check your setting like this:

#Azure CLI
az config get

This is what I get when I run the command:

az config get command output

To enable the feature you can run:

#Azure CLI
az config set auto-upgrade.enable=yes

If you run again the previous command you will now get the added section of configuration for the automatic upgrades:

az config get command output enriched with the automatic upgrades feature

You can turn back to the default behavior by issuing the set command but this time equals to “no:

#Azure CLI
az config set auto-upgrade.enable=no

Also, if you wish to disable prompts when a new update is available you can add the following configuration setting:

#Azure CLI
az config set auto-upgrade.prompt=no

This results to this final configuration:

final configuration output with "no-prompt" setting in place

Installed extensions and upgrades

If you want to change the default behavior of the upgrade process, and upgrade the extensions manually you can set the following configuration entry:

#Azure CLI
az config set auto-upgrade.all=no

Till next time,
Cheers!