LoginSignup
1
1

More than 1 year has passed since last update.

Azure CLI をインストールする手順

Last updated at Posted at 2023-02-11

Azure CLI をインストールする手順

目的

Microsoft のクラウド環境 Azure の理解を深めます。

実現すること

ローカル環境 (Ubuntu) に Microsoft のクラウド環境 Azure を操作する為のコマンドラインツール Azure CLI をインストールします。

開発環境

  • Windows 11 Home 22H2 を使用しています。
  • WSL の Ubuntu を操作していきますので macOS の方も参考にして頂けます。

WSL (Microsoft Store アプリ版)

> wsl --version
WSL バージョン: 1.0.3.0
カーネル バージョン: 5.15.79.1
WSLg バージョン: 1.0.47

Ubuntu

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04

※ この記事では基本的に Ubuntu のターミナルで操作を行います。

インストール

Microsoft Azure CLI リポジトリを登録

$ echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/azure-cli.list

パッケージ署名キーをインポート

$ curl -L https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

パッケージのインデックス更新

$ sudo apt update

Azure CLI インストール

$ sudo apt install azure-cli

Azure CLI のバージョンを確認

$ az --version
azure-cli                         2.45.0
core                              2.45.0
telemetry                          1.0.8
Dependencies:
msal                              1.20.0
azure-mgmt-resource             21.1.0b1

サインイン

Azure アカウントにサインイン

$ az login

※ WSLg でWEBブラウザが立ち上がります。

  • WEBブラウザのフォームに Microsoft アカウントを入力します。

ターミナルの出力

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": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "isDefault": true,
    "managedByTenants": [],
    "name": "Azure subscription 1",
    "state": "Enabled",
    "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "user": {
      "name": "username@gmail.com",
      "type": "user"
    }
  }
]

公式リファレンス

Azure コマンド ライン インターフェイス (CLI) ドキュメント

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1