LoginSignup
6
4

More than 3 years have passed since last update.

azコマンドで使うAzureサブスクリプションの変更

Posted at

サブスクリプションの変更

Azureの試用期間が終わり「無料試用版」を「従量課金」サブスクリプションに切り替えたがazコマンドで従量課金のサブスクリプションが適用されず今まで使っていたazコマンドが動かない。

次のようなメッセージがでる。

The subscription 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' is disabled and therefore marked as read only. You cannot perform any write actions on this subscription until it is re-enabled.

デフォルトのサブスクリプションの変更方法が複数の Azure サブスクリプションの使用に載っている。

$ az account list --output table --all                                                                                                                                                
Name        CloudName    SubscriptionId                        State     IsDefault
----------  -----------  ------------------------------------  --------  -----------
無料試用版  AzureCloud   XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX  Disabled  True
従量課金    AzureCloud   YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY  Enabled   False
$

デフォルトの変更

$ az account set --subscription YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY                                                                                                                 

これでデフォルトが切り替わりました。

$ az account list --output table --all                                                                                                                                               
Name        CloudName    SubscriptionId                        State     IsDefault
----------  -----------  ------------------------------------  --------  -----------
無料試用版  AzureCloud   XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX  Disabled  False
従量課金    AzureCloud   YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY  Enabled   True
$
6
4
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
6
4