如何在 Windows 上更新 azure-cli?

How to update azure-cli on Windows?

az --version 告诉我更新我的 CLI 安装,但没有解释要做什么。 那么安装更新的 az 命令是什么(如果有的话)?我似乎无法在任何地方找到它。

我试过在这里寻找答案:https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest and here: https://github.com/MicrosoftDocs/azure-docs-cli/issues/1341 但似乎找不到与更新相关的任何内容。

my-username@Azure:~$ az --versionazure-cli                         2.0.72 *
command-modules-nspkg               2.0.3
core                              2.0.72 *
nspkg                              3.0.4
telemetry                          1.0.3

Extensions:
interactive                        0.4.3

Python location '/opt/az/bin/python3'
Extensions directory '/home/my-username/.azure/cliextensions'

Python (Linux) 3.6.5 (default, Aug 22 2019, 06:32:32)
[GCC 5.4.0 20160609]

Legal docs and information: aka.ms/AzureCliLegal


You have 2 updates available. Consider updating your CLI installation.

我正在寻找类似于 Linux 中的 apt-get 命令的东西,用于安装、升级和清理包。

查看文档:https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest#install-or-update

您可以从那里下载新的安装程序并执行它来更新您的 CLI 版本。

根据您所说的:

I'm looking for something similar to apt-get command in Linux for installing, upgrading and cleaning packages.

您可以在 Chocolatey 的帮助下更新 Azure CLI。 Chocolatey 是 Windows 的包管理器(类似于 apt-get 但 Windows)。

一旦你安装了 Chocolatey(我在 Windows 上的大部分应用程序安装中都使用它),你可以从命令行安装你想要更新的 Azure CLI 包:

choco upgrade azure-cli

您最终会看到这样的屏幕:

正如您从上一张图片中看到的,我正在从版本 2.0.45 更新到版本 2.8.0。 安装完成后,您应该可以看到 ii 反映:

az --version
azure-cli                          2.8.0

...

Your CLI is up-to-date.

希望对您有所帮助。

来自Microsoft's documentation

The CLI provides an in-tool command to update to the latest version:

az upgrade

但是文档说明:

The az upgrade command was added in version 2.11.0 and will not work with versions prior to 2.11.0.

对于 Ubuntu / Linux 尝试使用下面的内联脚本。

pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge