静默安装Azure CLI

Azure的CLI目前已经是基于Python的2.0版本。其信息在下面的链接可以找到:

https://github.com/Azure/azure-cli

其安装方法可以根据网站上描述的命令实现:

curl -L https://aka.ms/InstallAzureCli | bash

但这种安装模式是交互式的,不能实现静默安装。

本文将介绍如何采用expect实现静默安装。

一、说明

根据https://docs.microsoft.com/en-us/cli/azure/install-az-cli2中描述的安装指南,在安装CLI前,有一些准备工作:

我用的是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来实现预期的交互安装。

二、安装

两个脚本:

1. installAzureCli.sh

做安装前的准备工作,并调用expect的脚本:

#!/bin/bash
yum update
yum install -y expect
yum install -y gcc libffi-devel python-devel openssl-devel
expect test.sh

2. test.sh

进行安装:

#!/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设置比较长,是保证在安装时不会中断,安装中都是默认回车就ok,所以全部是发送回车即可。

三、验证

输入:

[[email protected] 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.
……

说明已经安装成功。

[[email protected] test]# az --version
azure-cli (2.0.6)
 
acr (2.0.4)
acs (2.0.6)
appservice (0.1.6)
……..

可以检查其版本。

时间: 2025-01-15 22:01:33

静默安装Azure CLI的相关文章

安装 Azure CLI

首先安装node 和 npm 的安装 官方推荐v4.4.4长期支持版 1.下载并解压 node-v4.4.4-linux-x64.tar.xz tar -xJf node-v4.4.4-linux-x64.tar.xz 2.移到通用的软件安装目录 /opt/ sudo mv node-v4.4.4-linux-x64 /opt/ 3.安装 npm 和 node 命令到系统命令 sudo ln -s /opt/node-v4.4.4-linux-x64/bin/node /usr/local/bi

Linux CentOS安装Azure Cli工具

vim /etc/yum.repos.d/epel.repo [epel] name=epel baseurl=http://mirrors.sohu.com/fedora-epel/6/$basearch enabled=1 gpgcheck=0 用yum安装nodejs和npm软件: yum install nodejs -y yum install npm -y 编辑 ~/.npmrc 加入下面内容: registry = http://registry.cnpmjs.org 然后安装az

解决Azure CLI vm quick-create command failed

在安装Azure CLI 之后,迫不及待的想用vm quick-create command 创建一台虚拟机.结果遇到如下图中的错误 从错误提示中可以看出是缺少ssh file导致, 解决办法: ------------------------------------------------------ ssh-keygen \   -t rsa \    -b 2048 \    -C "[email protected]" \    -f ~/.ssh/id_rsa \    -N

Azure CLI下载Azure Storage Container内的所有文件

在某些场景下,客户需要把Azure Storage的某一个container内的内容都下载到本地.当然采用PowerShell可以定时的进行下载的动作,但有时客户的环境是Linux或MacOS,这时需要采用Azure xplate CLI实现这个功能.本文将介绍如何采用Azure CLI实现这个功能. 安装Azure CLI,可以参考: http://www.cnblogs.com/hengwei/p/5183493.html http://www.cnblogs.com/hengwei/p/4

Azure CLI (一)如何安装和配置Azure CLI

什么是Azure CLI 快速安装 Azure 命令行界面 (Azure CLI),以便使用一组基于 shell 的开源命令在 Azure 中创建和管理资源. 步骤 1:安装 . 登录https://www.azure.cn/downloads/,下载命令行工具,Azure命令行借口 . 安装下载的程序,Web平台安装程序,选择Microsoft Azure Cross-platform Command Line Tools 步骤 2:启动 . 运行 命令提示符CMD,输入Azure,得到Cur

Oracle静默安装

测试CentOS 6.5_x64下静默安装Oracle 11g R2数据库 [一.下载地址] http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html Oracle 11g 联机文档: http://www.oracle.com/pls/db112/homepage [二.系统要求] 内存:1G(官方最低要求1G) 硬盘:40G(企业版安装所需4.29G和1.7G数据文件) 检查的命令 内

Oracle 11g 基于CentOS7静默安装教程(无图形界面,远程安装)

一.安装前环境准备 1.  VMware Workstation 10 搭建 CentOS 7 x64位虚拟机,CentOS7操作系统最小化安装,2G内存,20G磁盘空间,1核CPU,已配置好网络IP:192.168.1.30 2.  已下载Oracle 11gLinux安装文件:linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.zip 3.  通过XmanagerXftp上传到虚拟机/tmp目录中. 二.操作系统准备

Linux静默安装Oracle

打算在云服务器上装oracle服务,以前DBA美眉都是在图形化界面下安装,这次抓瞎了.赶紧上网查查,静默安装可以解决问题.于是乎赶紧开始部署,过程如下.安装环境:操作系统:CentOS 7内存:11G(11851M)硬盘:128Goracle版本 11g 1.准备oracle 安装包 linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip 2.检查本机依赖包,没找到的用 yum install ****** 命令

Oracle11gR2 for Linux6.4 静默安装

Oracle11gR2 for Linux6.4 静默安装 1.安装准备 ####################################### 主机:window7,64位 数据库版本:Oracle Database 11.2.0.1 ,将装在虚拟主机中 虚拟主机:RHEL6.4 Server,32位(镜像文件:rhel-server-6.4-i386-dvd.iso, vmware虚拟机,操作系统仅安装了基本服务,简体中文,2G内存,20磁盘空间). 所有操作无需使用图形界面. 静默