5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure CLI ・Azure PowerShell で Subscription / Tenant を指定して Azure にログインする

Last updated at Posted at 2023-03-16

こんにちは、駆け出しアーキテクトのやまぱんです。
最近複数の Azure のテナント環境、Subscription 環境をまたいで作業することが多いので自分用にメモしておきます。

Azure CLI

現在ログインしているテナントとSubscriptionを確認する

Azure CLI
az account show

実行参考画面
2023-10-24_11h45_02.png

テナントを指定してログインする

Azure CLI
az login --tenant <テナントドメイン(例:XXXXXX.onmicrosoft.com)> or <オブジェクトID> 

--tenant 引数を使用すると、サインインするテナントを選択できます。 この引数の値として、.onmicrosoft.com ドメインまたはテナントの Azure オブジェクト ID を指定できます。

Subscription を指定する(切り替える)

Azure CLI
az account set -n <Subscription ID>
  • az account set

Azure PowerShell

Azure PowerShell の場合も追記しておきます。

ログインしているSubscription 、テナントID を表示

Azure PowerShell
Get-AzContext

Subscription IDを指定してログイン

Azure PowerShell
Connect-AzAccount -Subscription <Subscription ID>

Tenant とSubscription IDを指定してログイン

Azure PowerShell
Connect-AzAccount -Tenant <TenantID/ディレクトリID> -SubscriptionId <Subscription ID>

2023-11-01_15h40_01.png

Azure Portal でのテナントID確認方法

ディレクトリの切り変え → ディレクトリIDがTenantIDです。
2023-12-19_16h30_39.png

5
5
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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?