使用 zypper 安裝 Azure CLIInstall Azure CLI with zypper

對於 Linux zypper 所隨附的散發套件 (如 openSUSE 或 SLES),有適用於 Azure CLI 的套件。For Linux distributions with zypper, such as openSUSE or SLES, there's a package available for the Azure CLI. 此套件已經過 openSUSE 42.2、SLES 12 SP 2 及個別的更新版本測試。This package has been tested with openSUSE 42.2 and later, and SLES 12 SP 2 and later.

目前的 CLI 版本為 2.0.66The current version of the CLI is 2.0.66. 如需最新版本的相關資訊,請參閱版本資訊For information about the latest release, see the release notes. 若要找出已安裝的版本,並查看是否需要更新,請執行 az --versionTo find your installed version and see if you need to update, run az --version.


Azure CLI 的 RPM 套件會相依於 python 套件。The RPM package of the Azure CLI depends on the python package. 在您的系統上,這可能是早於 Python 2.7.x 需求的 Python 版本。On your system, this may be a Python version which predates the requirement of Python 2.7.x. 如果這會影響您,請尋找替代的 python 套件,或遵循手動安裝指示If this affects you, find a replacement python package or follow the manual install instructions.

請注意,Python 2 將在 2020 年 1 月 1 日停止支援,而且不會再收到更新。Be aware that Python 2 is being end-of-lifed on January 1, 2020, and will no longer receive updates. 基於這個理由,請盡可能升級到 Python 3。For this reason, upgrade to Python 3 when possible. Azure CLI 可與 Python 3.6 和更新版本相容。The Azure CLI is compatible with Python 3.6 and higher.


  1. 安裝 curlInstall curl:

    sudo zypper install -y curl
  2. 匯入 Microsoft 存放庫金鑰:Import the Microsoft repository key:

    sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
  3. 建立本機 azure-cli 存放庫資訊:Create local azure-cli repository information:

    sudo zypper addrepo --name 'Azure CLI' --check https://packages.microsoft.com/yumrepos/azure-cli azure-cli
  4. 更新 zypper 套件索引並安裝:Update the zypper package index and install:

    sudo zypper install --from azure-cli -y azure-cli

然後您可以使用 az 命令執行 Azure CLI。You can then run the Azure CLI with the az command. 若要登入,請使用 az login 命令。To sign in, use az login command.

  1. 執行 login 命令。Run the login command.

    az login

    如果 CLI 可以開啟預設瀏覽器,它會執行這項操作,並載入登入頁面。If the CLI can open your default browser, it will do so and load a sign-in page.

    否則,您需要開啟瀏覽器頁面,並遵循命令列中的指示,在瀏覽器中瀏覽至 https://aka.ms/devicelogin 之後,輸入授權碼。Otherwise, you need to open a browser page and follow the instructions on the command line to enter an authorization code after navigating to https://aka.ms/devicelogin in your browser.

  2. 請在瀏覽器中使用您的帳戶認證登入。Sign in with your account credentials in the browser.

若要深入了解不同的驗證方法,請參閱使用 Azure CLI 登入To learn more about different authentication methods, see Sign in with Azure CLI.


以下是一些使用 zypper 安裝時常見的問題。Here are some common problems seen when installing with zypper. 如果您遇到此處未涵蓋的問題,在 github 上提出問題If you experience a problem not covered here, file an issue on github.

Proxy 封鎖連線Proxy blocks connection

如果因為 Proxy 而無法連線到外部資源,請確定您已正確設定殼層中的 HTTP_PROXYHTTPS_PROXY 變數。If you're unable to connect to an external resource due to a proxy, make sure that you've correctly set the HTTP_PROXY and HTTPS_PROXY variables in your shell. 您必須連絡系統管理員,了解這些 Proxy 使用的主機和連接埠。You will need to contact your system administrator to know what host(s) and port(s) to use for these proxies.

包括用於安裝程序中的許多 Linux 程式都會接受這些值。These values are respected by many Linux programs, including those which are used in the install process. 若要設定這些值:To set these values:

# No auth
export HTTP_PROXY=http://[proxy]:[port]
export HTTPS_PROXY=https://[proxy]:[port]

# Basic auth
export HTTP_PROXY=http://[username]:[password]@[proxy]:[port]
export HTTPS_PROXY=https://[username]:[password]@[proxy]:[port]


如果您使用 Proxy,這些殼層變數必須設為使用 CLI 連線到 Azure 服務。If you are behind a proxy, these shell variables must be set to connect to Azure services with the CLI. 如果您並未使用基本驗證,建議您匯出 .bashrc 檔案中的這些變數。If you are not using basic auth, it's recommended to export these variables in your .bashrc file. 務必遵循您的企業安全性原則和系統管理員的需求。Always follow your business' security policies and the requirements of your system administrator.

建議您明確地將 zypper (透過 yast2) 明確設定為一律使用此 Proxy。You may also want to explicitly configure zypper (via yast2) to use this proxy at all times. 若要這樣做,請以超級使用者的角色執行 yast2 proxy 命令,並在表單中填寫相關資訊。To do so, run the yast2 proxy command as superuser, and fill in the information presented in the form. 如果您可在系統上使用視窗管理員,也可以使用 Network Services > Proxy 中的 YaST Control Center 窗格。If you have a window manager available on your system, you can also use the Network Services > Proxy pane in the YaST Control Center.

如需進階組態或詳細資訊,請參閱 OpenSUSE Proxy 設定文件For advanced configuration or more information, see the OpenSUSE Proxy configuration documentation

若要取得 Microsoft 簽署金鑰,並從我們的存放庫取得套件,您的 Proxy 必須允許 HTTPS 連線至下列位址:In order to get the Microsoft signing key and get the package from our repository, your proxy needs to allow HTTPS connections to the following addresses:

  • https://packages.microsoft.com
  • https://download.opensuse.org

無法在適用於 Linux 的 Windows 子系統上安裝 CLI,或無法在適用於 Linux 的 Windows 子系統上執行 CLICLI fails to install or run on Windows Subsystem for Linux

由於適用於 Linux 的 Windows 子系統 (WSL) 是 Windows 平台上的系統呼叫轉譯層,因此您在嘗試安裝或執行 Azure CLI 時,可能會發生錯誤。Since Windows Subsystem for Linux (WSL) is a system call translation layer on top of the Windows platform, you might experience an error when trying to install or run the Azure CLI. CLI 所依賴的部分功能,在 WSL 中可能出現錯誤 (bug)。The CLI relies on some features that may have a bug in WSL. 無論您使用何種方式安裝 CLI,若發生錯誤,很有可能是因為 WSL 的問題所導致,並非是 CLI 安裝程序發生問題。If you experience an error no matter how you install the CLI, there's a good chance it's an issue with WSL and not with the CLI install process.

若要針對 WSL 安裝進行疑難排解,並找出可以解決問題的辦法:To troubleshoot your WSL installation and possibly resolve issues:

  • 若是可以,請在 Linux 機器或 VM 上執行相同的安裝程序,查看是否能成功安裝。If you can, run an identical install process on a Linux machine or VM to see if it succeeds. 若安裝成功,則表示問題通常都與 WSL 有關。If it does, your issue is almost certainly related to WSL. 若要在 Azure 中啟動 Linux VM,請參閱在 Azure 入口網站中建立 Linux VM 文件。To start a Linux VM in Azure, see the create a Linux VM in the Azure Portal documentation.
  • 請確認您執行的是最新版本的 WSL。Make sure that you're running the latest version of WSL. 若要取得最新版本,請更新您的 Windows 10 安裝To get the latest version, update your Windows 10 installation.
  • 查看所有與 WSL 相關的未結問題,看看是否與您遇到的問題相關。Check for any open issues with WSL which might address your problem. 通常這些未結問題中會提供解決問題的建議,或是提供問題已解決的版本相關資訊。Often there will be suggestions on how to work around the problem, or information about a release where the issue will be fixed.
  • 若在目前的未結問題中找不到相關的資訊,請提出新的 WSL 問題,且務必提供完整的相關資訊。If there are no existing issues for your problem, file a new issue with WSL and make sure that you include as much information as possible.

如果您在 WSL 上安裝及執行時持續發生問題,請考慮安裝適用於 Windows 的 CLIIf you continue to have issues installing or running on WSL, consider installing the CLI for Windows.


您可以使用 zypper update 命令更新套件。You can update the package with the zypper update command.

sudo zypper refresh
sudo zypper update azure-cli


如果您決定要解除安裝 Azure CLI,我們很遺憾您不再繼續使用。If you decide to uninstall the Azure CLI, we're sorry to see you go. 您在解除安裝之前,請使用 az feedback 命令,讓我們知道可以加強或修正之處。Before you uninstall, use the az feedback command to let us know what could be improved or fixed. 我們的目標是讓 Azure CLI 既沒有錯誤又易於使用。Our goal is to make the Azure CLI bug-free and user-friendly. 如果找到錯誤 (bug),希望您提出 GitHub 問題,非常感謝您。If you found a bug, we'd appreciate it if you file a GitHub issue.

  1. 從系統移除套件。Remove the package from your system.

    sudo zypper remove -y azure-cli
  2. 如果您不打算重新安裝 CLI,請移除存放庫資訊。If you don't plan to reinstall the CLI, remove the repository information.

    sudo zypper removerepo azure-cli
  3. 如果您移除存放庫資訊,也會移除 Microsoft GPG 簽章金鑰。If you removed the repository information, also remove the Microsoft GPG signature key.

    MSFT_KEY=`rpm -qa gpg-pubkey /* --qf "%{version}-%{release} %{summary}\n" | grep Microsoft | awk '{print $1}'`
    sudo rpm -e --allmatches gpg-pubkey-$MSFT_KEY

後續步驟Next Steps

現在您已安裝 Azure CLI,接下來請簡單認識一下其功能和常用命令。Now that you've installed the Azure CLI, take a short tour of its features and common commands.