我在安装 Azure CLI 时遇到问题。我尝试了三种方法,但都失败了。
前两个来自Install Azure CLI on Windows,我试过了
- 使用 PowerShell 安装 Azure CLI,以及
- 自行下载并安装最新版本的 Azure CLI .msi 文件。
- 我已经尝试删除它并使用 .msi 文件重新安装。
但对于所有情况,如果我输入az
,我会得到
az : The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program.
然后我尝试在 Linux 上安装 Azure CLI作为最后的手段,但它也失败了:
+ echo 'deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ bullseye main'
+ apt-get update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease
Hit:3 http://ftp.debian.org/debian bullseye-backports InRelease
Hit:4 http://deb.debian.org/debian bullseye-updates InRelease
Hit:5 http://ppa.launchpad.net/suntong001/ppa/ubuntu focal InRelease
Get:6 https://packages.microsoft.com/repos/azure-cli bullseye InRelease [10.4 kB]
Err:6 https://packages.microsoft.com/repos/azure-cli bullseye InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
Reading package lists... Done
W: http://security.debian.org/debian-security/dists/bullseye-security/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/bullseye/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://ftp.debian.org/debian/dists/bullseye-backports/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/bullseye-updates/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://ppa.launchpad.net/suntong001/ppa/ubuntu/dists/focal/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: https://packages.microsoft.com/repos/azure-cli/dists/bullseye/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: https://packages.microsoft.com/repos/azure-cli bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
E: The repository 'https://packages.microsoft.com/repos/azure-cli bullseye InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
在 Windows 上,您可以在此处找到 Azure CLI az.cmd:
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin
这个路径可以在环境变量中找到
Path
:电源外壳:
$Env:Path
如果使用 msi 文件安装 Azure CLI,它将安装应用程序并将位置添加到
Path
变量中。如果有打开的 PowerShell,
Path
则不会在后台自动刷新。您必须关闭 PowerShell 并打开一个新会话。通常,Path
会加载更新的内容。这种行为也适用于更多的应用程序。因此,重新启动机器可能是有意义的(或者如果您想安全起见)。
顺便说一句:也可以使用例如 Chocolatey在 Windows 11(无需重新启动)中刷新环境变量