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?

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

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