[A-00086]azure cliをbrewでインストールする

homebrewでazure cliをインストールする方法を記載する。

brew install azure-cli
MacBook-Pro ~ % brew install azure-cli
==> Downloading https://formulae.brew.sh/api/formula.jws.json
##O=#   #                                                                                                                                     
==> Downloading https://formulae.brew.sh/api/cask.jws.json
.....
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

version情報の確認を行います。

az --version
MacBook-Pro ~ % az --version
azure-cli                         2.50.0

core                              2.50.0
telemetry                          1.0.8

Dependencies:
msal                              1.22.0
azure-mgmt-resource             23.1.0b2

Python location '/usr/local/Cellar/azure-cli/2.50.0/libexec/bin/python'
Extensions directory '/Users/anonymous/.azure/cliextensions'

Python (Darwin) 3.10.12 (main, Jun 20 2023, 16:51:59) [Clang 13.0.0 (clang-1300.0.29.30)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

次にazureにログインします。

az login
MacBook-Pro ~ % az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
[
  {
    "cloudName": "AzureCloud",
    "homeTenantId": .....
    }
  }
]

上記でazure-cliの設定は完了です。

2023/08/11追記

pythonからazure-cli-clientをインストールする方法を追記しておきます。

参考文献はこちら

https://mentalized.net/journal/2022/08/24/azure-cli-without-homebrew/

下記のコマンドをターミナルで実行します。

pip3 install azure-cli

下記のコマンドでazコマンドが有効かを確認します。

az version
MacBook-Pro:rust$ az version
{
  "azure-cli": "2.51.0",
  "azure-cli-core": "2.51.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

azコマンドが有効でない場合は下記のコマンドよりazコマンドが格納されているかを確認

ls /Library/Frameworks/Python.framework/Versions/3.10/bin/az

存在すればexportで.bashrcもしくは.bash_profileにパスを追加

export PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin/:$PATH"

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

*