2017年1月12日 星期四

CentOS 7.3 install azure-cli 2.0

CentOS 7.3 install azure-cli 2.0

Prerequire Install packagess

yum check-update; sudo yum install -y gcc libffi-devel python-devel openssl-devel

安裝 azure-cli 2.0 過程

[root@centos ~]# curl -L https://aka.ms/InstallAzureCli | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   167  100   167    0     0    283      0 --:--:-- --:--:-- --:--:--   283
100   788  100   788    0     0    498      0  0:00:01  0:00:01 --:--:--     0
Downloading Azure CLI install script from https://azurecliprod.blob.core.windows.net/install.py to /tmp/azure_cli_install_tmp_v4nl.
######################################################################## 100.0%
Running install script.
-- Verifying Python version.
-- Python version 2.7.5 okay.
-- Verifying native dependencies.
-- Executing: 'rpm -q gcc libffi-devel python-devel openssl-devel'
-- Native dependencies okay.

===> In what directory would you like to place the install? (leave blank to use '/root/lib/azure-cli'): /var/lib/azure-cli
-- Creating directory '/var/lib/azure-cli'.
-- We will install at '/var/lib/azure-cli'.

===> In what directory would you like to place the 'az' executable? (leave blank to use '/root/bin'): /bin
-- The executable will be in '/usr/bin'.
-- Executing: ['/bin/python', 'virtualenv.py', '--python', '/bin/python', '/var/lib/azure-cli']
Already using interpreter /bin/python
New python executable in /var/lib/azure-cli/bin/python
Installing setuptools, pip, wheel...done.
-- Executing: ['/var/lib/azure-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpGyrpzA', 'azure-cli', '--upgrade']
Collecting azure-cli
...(省略)
...(省略)
...(省略)
===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n): Y

===> Enter a path to an rc file to update (leave blank to use '/root/.bashrc'): (按ENTER)
-- Backed up '/root/.bashrc' to '/root/.bashrc.backup'
-- Tab completion set up complete.
-- If tab completion is not activated, verify that '/root/.bashrc' is sourced by your shell.
--
-- ** WARNING: Other 'az' executables are on your $PATH. **
-- Conflicting paths: /bin/az
-- You can run this installation of the CLI with '/usr/bin/az'.
--
-- ** Run `exec -l $SHELL` to restart your shell. **
--
-- Installation successful.
-- Run the CLI with /usr/bin/az --help
安裝完後,就直接執行 exec -l $SHELL

觀察 cat ~/.bashrc

會在你的 ~/.basrc 檔案最後面新增二行
export PATH=$PATH:/usr/bin

source '/var/lib/azure-cli/az.completion'
上面的 source 是一開始執行script時,它會問你要不要換位置 In what directory would you like to place the install? (leave blank to use '/root/lib/azure-cli'):,如果有換的話,記得檢查一下當時填的路徑要跟source是要一致的,這樣才可以正常使用。

使用畫面

這樣就可以使用命令補全了 XDD
[root@centos ~]# az
account     ad          component   context     feedback    --help      network     policy      resource    tag         vmss
acr         appservice  configure   --debug     group       login       -o          provider    role        --verbose
acs         cloud       container   feature     -h          logout      --output    --query     storage     vm

Reference:

沒有留言:

張貼留言