
我在安裝 Azure CLI 時遇到問題。我嘗試了三種方法但都失敗了。
前兩個來自在 Windows 上安裝 Azure CLI, 我試過了
- 使用 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.
答案1
在 Windows 上,您可以找到 Azure CLIaz命令這裡:
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin
電源外殼:
$Env:Path
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;
如果使用 msi 檔案安裝 Azure CLI,它將安裝應用程式並將位置新增至Path
變數。
如果有開啟的 PowerShell,則Path
不會在背景自動刷新。您必須關閉 PowerShell 並開啟一個新會話。通常,Path
會載入更新的內容。這種行為也適用於更多的應用程式。
因此,重新啟動電腦可能是有意義的(或者如果您想安全起見)。
順便一提:也可以刷新 Windows 11 中的環境變數(無需重新啟動)與例如巧克力