静默安装Azure CLI
Azure的CLI目前已經(jīng)是基于Python的2.0版本。其信息在下面的鏈接可以找到:
https://github.com/Azure/azure-cli
其安裝方法可以根據(jù)網(wǎng)站上描述的命令實(shí)現(xiàn):
curl -L https://aka.ms/InstallAzureCli | bash但這種安裝模式是交互式的,不能實(shí)現(xiàn)靜默安裝。
本文將介紹如何采用expect實(shí)現(xiàn)靜默安裝。
一、說明
根據(jù)https://docs.microsoft.com/en-us/cli/azure/install-az-cli2中描述的安裝指南,在安裝CLI前,有一些準(zhǔn)備工作:
我用的是CentOS7.3版本的Linux,其Pre-Request為:
sudo yum check-update; sudo yum install -y gcc libffi-devel python-devel openssl-devel安裝命令為:
curl -L https://aka.ms/InstallAzureCli | bash由于安裝過程有交互,所以采用inspect來實(shí)現(xiàn)預(yù)期的交互安裝。
二、安裝
兩個(gè)腳本:
1. installAzureCli.sh
做安裝前的準(zhǔn)備工作,并調(diào)用expect的腳本:
#!/bin/bash yum update yum install -y expect yum install -y gcc libffi-devel python-devel openssl-devel expect test.sh2. test.sh
進(jìn)行安裝:
#!/usr/bin/expect -f set timeout 20000 spawn /bin/sh -c "curl -L https://aka.ms/InstallAzureCli | bash" expect "*)*" send "\r" expect "*)*" send "\r" expect "*)*" send "\r" expect "*)*" send "\r" expect "*)*" send "\r" interact其中timeout設(shè)置比較長,是保證在安裝時(shí)不會(huì)中斷,安裝中都是默認(rèn)回車就ok,所以全部是發(fā)送回車即可。
三、驗(yàn)證
輸入:
[root@hwwaf01 test]# az???? /\??? /? \??? _____?? _ _ __ ___
?? / /\ \? |_? / | | | \'__/ _ \
? / ____ \? / /| |_| | | |? __/
?/_/??? \_\/___|\__,_|_|? \___|Welcome to the cool new Azure CLI!Here are the base commands:account : Manage subscriptions. acr : Manage Azure container registries. acs : Manage Azure Container Services. ad : Synchronize on-premises directories and manage Azure Active Directory resources. appservice : Manage your App Service plans. batch : Manage Azure Batch. ……
說明已經(jīng)安裝成功。
[root@hwwaf01 test]# az --version azure-cli (2.0.6)acr (2.0.4) acs (2.0.6) appservice (0.1.6) ……..可以檢查其版本。
登錄AzureChina:
az cloud set --name AzureChinaCloud az login --username admin@xxxx.partner.onmschina.cn Password:輸入密碼后,就可以登錄了。
轉(zhuǎn)載于:https://www.cnblogs.com/hengwei/p/6837302.html
總結(jié)
以上是生活随笔為你收集整理的静默安装Azure CLI的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tr的display属性出现td的col
- 下一篇: spring4.2更好的应用事件