Azure CLI で Microsoft アカウントによるログインをサポート

このポストは、10 月 14 日に投稿された Azure CLI supports Microsoft Account logins の翻訳です。

Azure CLI v0.9.10 がリリースされ、Microsoft アカウント (Windows Live ID) からのログインがサポートされました。Azure CLI v0.9.10 は現在、WebPIMacNPM (英語)GitHub (英語) からご利用いただけます。

これまでのバージョンでは、Azure の組織アカウントおよびサービス プリンシパルで使用されている認証スキームのみがサポートされていました。今回のリリースを前に、Azure CLI ユーザーの皆様からは、Azure CLI にログインするだけのために、Azure Active Directory インスタンスでユーザーを作成する際に Azure 管理ポータルからログインする必要があり、この際に Microsoft アカウント (Windows Live ID) を使用することがよくあるという声をいただいていました。このフローでは簡単に新規ユーザーを Azure CLI に追加できるようになるため、今回 Azure Active Directory と組み合わせて、Azure CLI で Microsoft アカウントを使用して認証できる新しいフローを開発しました。

ログイン コマンドの Azure CLI ヘルプの内容

 azure login -h
help: Log in to an Azure subscription using Active Directory.
help:
help: Usage: login [options]
help:
help: Options:
help: -h, --help output usage information
help: -v, --verbose use verbose output
help: -vv more verbose with debug output
help: --json use json output
help: -u --username  user name or service principal ID
help: -e --environment [environment] Environment to authenticate against, must support active directory
help: -p --password  user password or service principal key, will prompt if not given
help: --service-principal If given, log in as a service principal rather than a user
help: --tenant  Tenant domain or ID to log into
help: -q --quiet do not prompt for confirmation of PII storage
help:
help: Current Mode: arm (Azure Resource Management)

azcli-login-h.sh hosted with ❤ by GitHub                                                view raw

Azure CLI で使用できる 3 種類の認証フロー

1. Microsoft アカウント (Windows Live ID) と組織アカウント

 # Running Azure login will prompt the user to open the device login page and start polling
# for confirmation of login.

azure login
# info: Executing command login
# info: To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code ####### 
# to authenticate. If you're signing in as an Azure AD application, use the --username and --password parameters.
# info: Added subscription Visual Studio Ultimate with MSDN
# info: login command OK

azcli-login-msa.sh hosted with ❤ by GitHub                                            view raw

2. 組織アカウント (Multi-Factor Authentication ではない場合)

 # Running Azure login with -u will prompt the user for their password
# and authenticate the Azure organizational account unless Multi-Factor
# Authentication is enabled. If Multi-Factor Authentication is enabled,
# the user will be prompted with the following error:
#
# error: Interactive login is required. Use 'azure login' to interactively login.

azure login -u your-username
# info: Executing command login
# Password: **************
# + Authenticating...
# info: Added subscription Visual Studio Ultimate with MSDN
# +
# info: login command OK

azcli-login-org.sh hosted with ❤ by GitHub                                             view raw

3. サービス プリンシパル (Azure Active Directory の Automation アカウント)

 # Running Azure login with --service-principal is intended for use in automation
# scenarios and does not require an interactive login.

azure login --service-principal -u client-id -p secret --tenant [tenant-guid | domain]
# info: Executing command login
# info: Added subscription Visual Studio Ultimate with MSDN
# +
# info: login command OK

azcli-login-sp.sh hosted with ❤ by GitHub                                               view raw

Azure Active Directory での認証の詳細については、Dushyant Gill のブログ記事「Azure Resource Manager での認証に関する開発者向けガイド (英語)」をお読みください。

Azure CLI でのログインが簡単に (おさらい)

 # Running Azure login will prompt the user to open the device login page and start polling
# for confirmation of login.

azure login
# info: Executing command login
# info: To sign in, use a web browser to open the page https://aka.ms/devicelogin. Enter the code ####### 
# to authenticate. If you're signing in as an Azure AD application, use the --username and --password parameters.
# info: Added subscription Visual Studio Ultimate with MSDN
# info: login command OK

azcli-login-msa.sh hosted with ❤ by GitHub                                            view raw