こんにちは、駆け出しアーキテクトのやまぱんです。
最近複数の Azure のテナント環境、Subscription 環境をまたいで作業することが多いので自分用にメモしておきます。
Azure CLI
現在ログインしているテナントとSubscriptionを確認する
Azure CLI
az account show
テナントを指定してログインする
Azure CLI
az login --tenant <テナントドメイン(例:XXXXXX.onmicrosoft.com)> or <オブジェクトID>
- 別のテナントでサインインする
https://learn.microsoft.com/ja-jp/cli/azure/authenticate-azure-cli#sign-in-with-a-different-tenant
--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>