安装Azure CLI 2.0的前提是:机器中必须有 Python 2.7.x 或 Python 3.x。如果机器中没有其中任何一个Python版本,请及时安装
1.准备一台CentOS 6.9的机器
[root@hlmcent69nma ~]# cat /etc/redhat-release CentOS release 6.9 (Final)
2.按照我的另一篇博客,安装Python 2.7.x
[root@hlmcent69nma ~]# python -V Python 2.7.14
3.导入 Microsoft 存储库密钥
[root@hlmcent69nma ~]# rpm --import https://packages.microsoft.com/keys/microsoft.asc
4.创建本地 azure-cli 存储库信息
[root@hlmcent69nma ~]# sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'
5.更新 yum 包索引并安装
[root@hlmcent69nma ~]# yum check-update [root@hlmcent69nma ~]# yum install azure-cli –y
6.发现安装“azure-cli”的时候会提示如下报错:
[root@hlmcent69nma ~]# yum install azure-cli -y Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package azure-cli.x86_64 0:2.0.22-1.el7 will be installed --> Processing Dependency: libpython2.7.so.1.0()(64bit) for package: azure-cli-2.0.22-1.el7.x86_64 --> Finished Dependency Resolution Error: Package: azure-cli-2.0.22-1.el7.x86_64 (azure-cli) Requires: libpython2.7.so.1.0()(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest
7.下载并更新libpython2.7依赖包
[root@hlmcent69nma ~]# wget https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64//python27-libs-2.7.14-1.ius.centos6.x86_64.rpm --2017-12-06 09:01:35-- https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64//python27-libs-2.7.14-1.ius.centos6.x86_64.rpm Resolving dl.iuscommunity.org... 146.20.25.47, 2001:4802:7901:0:4ccc:ff11:0:a Connecting to dl.iuscommunity.org|146.20.25.47|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6144844 (5.9M) [application/x-redhat-package-manager] Saving to: “python27-libs-2.7.14-1.ius.centos6.x86_64.rpm” 100%[===================================================================================================================================================>] 6,144,844 1.08M/s in 8.4s 2017-12-06 09:01:46 (718 KB/s) - “python27-libs-2.7.14-1.ius.centos6.x86_64.rpm” saved [6144844/6144844] [root@hlmcent69nma ~]# rpm -Uvh python27-libs-2.7.14-1.ius.centos6.x86_64.rpm warning: python27-libs-2.7.14-1.ius.centos6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 9cd4953f: NOKEY Preparing... ########################################### [100%] 1:python27-libs ########################################### [100%]
8.重新安装“azure-cli”,可以成功安装
[root@hlmcent69nma ~]# yum install azure-cli -y
9.使用 az 命令验证Azure CLI 2.0是否已经安装成功
[root@hlmcent69nma ~]# az
参考链接:
https://www.python.org/downloads/
https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
https://centos.pkgs.org/6/ius-x86_64/python27-libs-2.7.14-1.ius.centos6.x86_64.rpm.html
I hear and I forget. I see and I remeber. I do and I understand!