Azure サービスを使用して Python アプリを認証する方法How to authenticate Python apps with Azure services

Python 用 Azure ライブラリを使用してアプリのコードを記述するときは、次のパターンを使用して Azure リソースにアクセスします。When writing app code using the Azure libraries for Python, you use the following pattern to access Azure resources:

  1. 資格情報を取得します (通常は 1 回限りの操作)。Acquire a credential (typically a one time operation).
  2. その資格情報を使用して、リソースに適したクライアント オブジェクトを取得します。Use the credential to acquire the appropriate client object for a resource.
  3. そのクライアント オブジェクトを介してリソースにアクセスしたり変更を加えたりしようとすると、リソースの REST API に対する HTTP 要求が生成されます。Attempt to access or modify the resource through the client object, which generates an HTTP request to the resource's REST API.

この REST API への要求の時点で、資格情報オブジェクトによって表されたアプリの ID が Azure によって認証されます。The request to the REST API is the point at which Azure authenticates the app's identity as described by the credential object. その後 Azure は、要求された操作の実行がその ID に承認されているかどうかをチェックします。Azure then checks whether that identity is authorized to perform the requested action. 承認されていない場合、操作は失敗します。If the identity does not have authorization, the operation fails. (アクセス許可の付与は、Azure Key Vault、Azure Storage など、リソースの種類によって異なります。詳細については、リソースの種類に対応するドキュメントを参照してください。)(Granting permissions depends on the type of resource, such as Azure Key Vault, Azure Storage, etc. For more information, see the documentation for that resource type.)

これらのプロセスに関係する ID (つまり、資格情報オブジェクトによって表される ID) は通常、ユーザー、グループ、サービス、アプリのいずれかを表す "セキュリティ プリンシパル" によって定義されます。The identity involved in these processes, that is, the identity described by the credentials object, is generally defined by a that represents a user, group, service, or app. この記事で取り上げるさまざまな認証方法には、明示的なプリンシパル (一般に "サービス プリンシパル" と呼ばれます) を使用しています。A number of authentication methods described in this article use an explicit principal, which is typically referred to as a .

ただし、ほとんどのクラウド アプリケーションでは、最初のセクションで取り上げる DefaultAzureCredential オブジェクトの使用をお勧めします。アプリケーションのサービス プリンシパルを扱う負担は、このオブジェクトを使用することで大幅に軽減されます。For most cloud applications, however, we recommend using the object as explained in the first section, because it completely relieves you from handling a service principal for the application.

注意

Google Chrome の Cookie の処理方法に関して予定されている変更を受けて、Web サイトが期待どおりに動作することを確認する必要があります。You need to verify your website works as expected with the upcoming changes in how cookies are handled in Google Chrome. この変更は、クロスサイト リクエスト フォージェリ (CSRF) 攻撃を防止するのに役立ちますが、適切に対処しないと、既定の Cookie 処理 (Microsoft クラウドサービスや独自のものを含む) に依存する多くのアプリケーションやサービスに深刻な影響を及ぼします。Although the change helps prevent cross-site request forgery (CSRF) attacks, without proper remediation it will severely affect many applications and services that rely on today’s cookie handling defaults, including Microsoft cloud services or your own. この変更は、2020 年 2 月 4 日に向けたリリース 80 で Chrome の既定の動作としてロールアウトされる予定です。This change is expected to roll out as the default Chrome behavior in release 80 that is targeted for February 4, 2020. 詳細情報とアプリのテスト方法については、「Chrome バージョン 79 以降で、顧客の Web サイトと Microsoft 製品およびサービスが中断される可能性がある」をご参照ください。For more information and details on how to test your app, see .

DefaultAzureCredential を使用して認証するAuthenticate with DefaultAzureCredential

import os
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient

# Obtain the credential object. When run locally, DefaultAzureCredential relies
# on environment variables named AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID.
credential = DefaultAzureCredential()

# Create the client object using the credential
#
# **NOTE**: SecretClient here is only an example; the same process
# applies to all other Azure client libraries.

vault_url = os.environ["KEY_VAULT_URL"]
secret_client = SecretClient(vault_url=vault_url, credential=credential)

# Attempt to retrieve a secret value. The operation fails if the principal
# cannot be authenticated or is not authorized for the operation in question.
retrieved_secret = client.get_secret("secret-name-01")

azure-identity ライブラリの DefaultAzureCredential クラスには、きわめてシンプルな、推奨される認証手段が備わっています。The class from the library provides the simplest and recommended means of authentication.

前述のコードでは、Azure Key Vault へのアクセス時に DefaultAzureCredential が使用されています。Azure Key Vault では、Key Vault の URL が KEY_VAULT_URL という名前の環境変数で提供されます。The previous code uses the when accessing Azure Key Vault, where the URL of the Key Vault is available in an environment variable named . このコードは紛れもなく、記事の冒頭で説明したパターンで実装されています。つまり、資格情報オブジェクトを取得し、SDK クライアント オブジェクトを作成した後、そのクライアント オブジェクトを使用して操作を実行しています。The code clearly implements the pattern described at the beginning of the article: acquire a credential object, create an SDK client object, then attempt to perform an operation using that client object.

繰り返しになりますが、認証と承認は最後のステップで初めて実行されます。Again, authentication and authorization don't happen until the final step. SDK SecretClient オブジェクトの作成には、対象となるリソースとのやり取りは伴いません。SecretClient オブジェクトはあくまで、基になる Azure REST API のラッパーであり、アプリの実行時のメモリにのみ存在します。Creating the SDK object involves no communication with the resource in question; the object is just a wrapper around the underlying Azure REST API and exists only in the app's runtime memory. get_secret メソッドが呼び出されたときに初めて、クライアント オブジェクトが Azure に対して適切な REST API 呼び出しを生成します。It's only when you call the method that the client object generates the appropriate REST API call to Azure. その後、get_secret に対応する Azure のエンドポイントで、呼び出し元の ID が認証され、承認がチェックされます。Azure's endpoint for then authenticates the caller's identity and checks authorization.

コードを Azure にデプロイして実行した場合、DefaultAzureCredential によって自動的にシステム割り当て ("マネージド") の ID が使用されます。このマネージド ID は、そのホストとなるあらゆるサービス内のアプリに対して有効にすることができます。When code is deployed to and running on Azure, automatically uses the system-assigned ("managed") identity assigned that you can enable for the app within whatever service is hosting it. たとえば、Azure App Service にデプロイされた Web アプリの場合、そのマネージド ID は、Azure portal の [ID] > [システム割り当て済み] オプションで有効にするか、Azure CLI で az webapp identity assign コマンドを使用して有効にします。For example, for a web app deployed to Azure App Service, you enable its managed identity through the > option in the Azure portal, or by using the command in the Azure CLI. その ID に対して特定のリソース (Azure Storage や Azure Key Vault など) のアクセス許可を割り当てる際にも、Azure portal または Azure CLI を使用します。Permissions for specific resources, such as Azure Storage or Azure Key Vault, are also assigned to that identity using the Azure portal or the Azure CLI. これらのケースでは、Azure によって管理されるこのマネージド ID によって最大限のセキュリティが確保されます。明示的なサービス プリンシパルをコード内で一切扱う必要がないためです。In these cases, this Azure-managed identity maximizes security because you don't ever deal with an explicit service principal in your code.

コードをローカルで実行した場合は、AZURE_TENANT_IDAZURE_CLIENT_IDAZURE_CLIENT_SECRET という名前の各環境変数によって表されるサービス プリンシパルが DefaultAzureCredential によって自動的に使用されます。When you run your code locally, automatically uses the service principal described by the environment variables named , , and . その後、API エンドポイントを呼び出すと、それらの値が SDK クライアント オブジェクトによって (安全に) HTTP 要求ヘッダーに追加されます。The SDK client object then includes these values (securely) in the HTTP request header when calling the API endpoint. コードに変更を加える必要はありません。No code changes are necessary. サービス プリンシパルの作成と環境変数の設定について詳しくは、「Azure 用のローカル Python 開発環境を構成する - 認証を構成する」を参照してください。For details on creating the service principal and setting up the environment variables, see .

どちらの場合も、関係する ID には、適切なリソースのアクセス許可を割り当てる必要があります (個々のサービスのドキュメントを参照)。In both cases, the identity involved must be assigned permissions for the appropriate resource, which is described in the documentation for the individual services. 前出のコードで必要となるような Key Vault のアクセス許可について詳しくは、「アクセス制御ポリシーを使用して Key Vault の認証を提供する」を参照してください。For details on Key Vault permissions, as would be needed for the previous code, see .

重要

将来的には、サービス プリンシパルの環境変数が利用できない場合、az login を通じて Azure CLI にサインインした ID が DefaultAzureCredential によって使用されます。In the future, will use the identity signed into the Azure CLI through if service principal environment variables aren't available. 結果的に、自分がサブスクリプションの所有者または管理者であれば、個別にアクセス許可を割り当てなくても、そのサブスクリプションのほとんどのリソースに対するアクセス権がコードに最初から割り当てられます。If you're the owner or administrator of your subscription, the practical upshot of this feature is that your code has inherent access to most resources in that subscription without having to assign any specific permissions. この動作は、実験目的であれば利便性が高いといえます。This behavior is convenient for experimentation. ただし、これから皆さんは、個々の ID に対して厳密にアクセス許可を割り当て、それらを運用環境にデプロイする前に、アクセス許可をテスト環境で正しく検証する方法を身に付けることになるでしょう。そのため、運用環境のコードを作成する段階になったら、個別のサービス プリンシパルを使用し、個別のアクセス許可を割り当てることを強くお勧めします。However, we highly recommend that you use specific service principals and assign specific permissions when you start writing production code because you'll learn how to assign exact permissions to different identities and can accurately validate those permissions in test environments before deploying to production.

SDK 管理ライブラリで DefaultAzureCredential を使用するUsing DefaultAzureCredential with SDK management libraries

# WARNING: this code presently fails!

from azure.identity import DefaultAzureCredential

# azure.mgmt.resource is an Azure SDK management library
from azure.mgmt.resource import SubscriptionClient

# Attempt to retrieve the subscription ID
credential = DefaultAzureCredential()
subscription_client = SubscriptionClient(credential)

# The following line produces a "no attribute 'signed_session'" error:
subscription = next(subscription_client.subscriptions.list())

print(subscription.subscription_id)

現在、DefaultAzureCredential の使用は、Azure SDK クライアント ("データ プレーン") ライブラリに限定されます。このコード例に示したような、名前が azure-mgmt で始まる Azure SDK 管理ライブラリでは正しく機能しません。At present, works only with Azure SDK client ("data plane") libraries, and does not work with Azure SDK management libraries whose names begin with , as show in this code example. subscription_client.subscriptions.list() を呼び出すと、"'DefaultAzureCredential' オブジェクトに属性 'signed_session' が存在しない" という内容のかなり不明瞭なエラーが発生します。The call to fails with the rather vague error, "'DefaultAzureCredential' object has no attribute 'signed_session'". 現在の SDK 管理ライブラリは、資格情報オブジェクトに signed_session プロパティが存在することを前提としていますが、DefaultAzureCredential にはこのプロパティが欠落しています。このエラーが発生するのは、そのためです。This error happens because the current SDK management libraries assume that the credential object contains a property, which lacks.

今後 2020 年内にこれらのライブラリが更新されるまでは、次の 2 とおりの方法でエラーを回避してください。Until those libraries are updated later in 2020, you can work around the error in two ways:

  1. この記事の後続のセクションで取り上げる他のいずれかの認証方法を使用します。SDK 管理ライブラリ "のみ" を使用し、なおかつクラウドにデプロイされないコードであれば、これらの認証方法がうまく機能します。この場合、利用できるのはローカルのサービス プリンシパルのみです。Use one of the other authentication methods describe in subsequent sections of this article, which can work well for code that uses SDK management libraries and that won't be deployed to the cloud, in which case you can rely on local service principals only.

  2. Azure SDK エンジニアリング チームのメンバーから提供されている CredentialWrapper クラス (cred_wrapper.py)DefaultAzureCredential の代わりに使用します。Instead of , use the that's provided by a member of the Azure SDK engineering team. 更新された管理ライブラリが Microsoft からリリースされたら、DefaultAzureCredential に戻すだけで済みます。Once Microsoft releases the updated management libraries, you can simply switch back to . この方法の利点は、SDK クライアントと管理ライブラリの両方で同じ資格情報を使用できる点、またローカルでもクラウドでも使用できる点です。This method has the advantage that you can use the same credential with both SDK client and management libraries, and it works both locally and in the cloud.

    プロジェクト フォルダーに cred_wrapper.py のコピーがダウンロード済みである場合、先ほどのコードは次のようになります。Assuming that you've downloaded a copy of into your project folder, the previous code would appear as follows:

    from cred_wrapper import CredentialWrapper
    from azure.mgmt.resource import SubscriptionClient
    
    credential = CredentialWrapper()
    subscription_client = SubscriptionClient(credential)
    subscription = next(subscription_client.subscriptions.list())
    print(subscription.subscription_id)
    

    管理ライブラリが更新されたら、DefaultAzureCredential を直接使用できます。Once the management libraries are updated, you can use directly.

その他の認証方法Other authentication methods

DefaultAzureCredential は、ほとんどのシナリオで推奨される認証方法ですが、次の注意事項の下で他の方法も利用できます。Although is the recommended authentication method for most scenarios, other methods are available with the following caveats:

  • それらの方法の大半は、明示的なサービス プリンシパルで動作し、クラウドにデプロイされたコードでマネージド ID の利点が活かされません。Most of the methods work with explicit service principals and don't take advantage of managed identity for code that's deployed to the cloud. 運用環境のコードで使用する場合は、対象のクラウド アプリケーション用に別個のサービス プリンシパルを自分で管理、保守する必要があります。When used with production code, then, you must manage and maintain distinct service principals for your cloud applications.

  • CLI ベースの認証など一部の方法はローカル スクリプトでしか機能せず、運用環境のコードでは使用できません。Some methods, such as CLI-based authentication, work only with local scripts and cannot be used with production code.

クラウドにデプロイされたアプリケーションのサービス プリンシパルは、ご利用のサブスクリプションの Active Directory で管理されます。Service principals for applications deployed to the cloud are managed in your subscriptions Active Directory. 詳細については、「サービス プリンシパルを管理する方法」を参照してください。For more information, see .

JSON ファイルを使用して認証するAuthenticate with a JSON file

この方法では、サービス プリンシパルに必要な資格情報を含む JSON ファイルを作成します。In this method, you create a JSON file that contains the necessary credentials for the service principal. そのファイルを使用して SDK クライアント オブジェクトを作成します。You then create an SDK client object using that file. この方法は、ローカルでもクラウドでも使用できます。This method can be used both locally and in the cloud.

  1. 次の形式の JSON ファイルを作成します。Create a JSON file with the following format:

    {
        "subscriptionId": "<azure_aubscription_id>",
        "tenantId": "<tenant_id>",
        "clientId": "<application_id>",
        "clientSecret": "<application_secret>",
        "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
        "resourceManagerEndpointUrl": "https://management.azure.com/",
        "activeDirectoryGraphResourceId": "https://graph.windows.net/",
        "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
        "galleryEndpointUrl": "https://gallery.azure.com/",
        "managementEndpointUrl": "https://management.core.windows.net/"
    }
    

    4 つのプレースホルダーは、Azure サブスクリプション ID、テナント ID、クライアント ID、クライアント シークレットに置き換えてください。Replace the four placeholders with your Azure subscription ID, tenant ID, the client ID, and the client secret.

    ヒント

    ローカル開発環境の構成に関するセクションで説明されているように、az ad sp create-for-rbac コマンドに --sdk-auth パラメーターを指定することで、この JSON 形式をすぐに生成できます。As explained in , you can use the command with the parameter to generate this JSON format directly.

  2. ファイルに名前 (credentials.json など) を付けて、コードからアクセスできる安全な場所に保存します。Save the file with a name like in a secure location that your code can access. 資格情報の安全性を確保するため、このファイルはソース管理から除外し、他の開発者と共有しないようにしてください。To keep your credentials secure, be sure to omit this file from source control and don't share it with other developers. つまり、サービス プリンシパルのテナント ID、クライアント ID、クライアント シークレットは、常に自分の開発ワークステーションで隔離されている必要があります。That is, the tenant ID, client ID, and client secret of a service principal should always remain isolated on your development workstation.

  3. JSON ファイルのパスを値とする AZURE_AUTH_LOCATION という名前の環境変数を作成します。Create an environment variable named with the path to the JSON file as the value:

    set AZURE_AUTH_LOCATION=../credentials.json
    

    この例では、JSON ファイルが credentials.json という名前でプロジェクトの親フォルダーに格納されていることを想定しています。These examples assume the JSON file is named and is located in the parent folder of your project.

  4. get_client_from_auth_file メソッドを使用してクライアント オブジェクトを作成します。Use the method to create the client object:

    from azure.common.client_factory import get_client_from_auth_file
    from azure.mgmt.resource import SubscriptionClient
    
    # This form of get_client_from_auth_file relies on the AZURE_AUTH_LOCATION
    # environment variable.
    subscription_client = get_client_from_auth_file(SubscriptionClient)
    
    subscription = next(subscription_client.subscriptions.list())
    print(subscription.subscription_id)
    

または、auth_path 引数を使用してコード内で直接パスを指定してもかまいません。その場合、環境変数は不要です。You can alternately specify the path directly in code by using the argument, in which case the environment variable isn't needed:

subscription_client = get_client_from_auth_file(SubscriptionClient, auth_path="../credentials.json")

JSON ディクショナリを使用した認証Authenticate with a JSON dictionary

import os
from azure.common.client_factory import get_client_from_json_dict
from azure.mgmt.resource import SubscriptionClient

# Retrieve the IDs and secret to use in the JSON dictionary
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
tenant_id = os.environ["AZURE_TENANT_ID"]
client_id = os.environ["AZURE_CLIENT_ID"]
client_secret = os.environ["AZURE_CLIENT_SECRET"]

config_dict = {
   "subscriptionId": subscription_id,
    "tenantId": tenant_id,
   "clientId": client_id,
   "clientSecret": client_secret,
   "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
   "resourceManagerEndpointUrl": "https://management.azure.com/",
   "activeDirectoryGraphResourceId": "https://graph.windows.net/",
   "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
   "galleryEndpointUrl": "https://gallery.azure.com/",
   "managementEndpointUrl": "https://management.core.windows.net/"
}

subscription_client = get_client_from_json_dict(SubscriptionClient, config_dict)

subscription = next(subscription_client.subscriptions.list())
print(subscription.subscription_id)

前のセクションで説明したように、ファイルを使用する代わりに、必要な JSON データを変数に作成し、get_client_from_json_dict を呼び出すことができます。Instead of using a file, as described in the previous section, you can build the necessary JSON data in a variable and call . このコードは、ローカル開発環境の構成に関するセクションで説明されている環境変数が作成済みであることを想定しています。This code assumes that you've created the environment variables described in . クラウドにデプロイされるコードの場合、これらの環境変数をサーバー VM 上に作成できるほか、Azure App Service や Azure Functions などのプラットフォーム サービスを使用しているときは、アプリケーション設定として作成することができます。For code deployed to the cloud, you can create these environment variables on your server VM or as application settings when using platform service like Azure App Service and Azure Functions.

または、環境変数を使わずに、値を Azure Key Vault に格納して実行時に取得してもかまいません。You can also store values in Azure Key Vault and retrieve them at run time rather than using environment variables.

トークン資格情報で認証を行うAuthenticate with token credentials

import os
from azure.mgmt.resource import SubscriptionClient
from azure.common.credentials import ServicePrincipalCredentials

# Retrieve the IDs and secret to use with ServicePrincipalCredentials
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
tenant_id = os.environ["AZURE_TENANT_ID"]
client_id = os.environ["AZURE_CLIENT_ID"]
client_secret = os.environ["AZURE_CLIENT_SECRET"]

credential = ServicePrincipalCredentials(tenant=tenant_id, client_id=client_id, secret=client_secret)

subscription_client = SubscriptionClient(credential)

subscription = next(subscription_client.subscriptions.list())
print(subscription.subscription_id)

この方法では、Azure Key Vault や環境変数など、安全な記憶域から取得した資格情報を使用して ServicePrincipalCredentials オブジェクトを作成します。In this method, you create a object using credentials obtained from secure storage such as Azure Key Vault or environment variables. 前のコードは、ローカル開発環境の構成に関するセクションで説明されている環境変数が作成済みであることを想定しています。The previous code assumes that you've created the environment variables described in .

この方法を使用した場合は、クライアント オブジェクトに base_url 引数を指定することで、Azure パブリック クラウドではなく Azure ソブリン クラウド (国内クラウド) を使用できます。With this method, you can use an rather than the Azure public cloud by specifying a argument for the client object:

from msrestazure.azure_cloud import AZURE_CHINA_CLOUD

#...

subscription_client = SubscriptionClient(credentials, base_url=AZURE_CHINA_CLOUD.endpoints.resource_manager)

ソブリン クラウドの定数は、msrestazure.azure_cloud ライブラリにあります。Sovreign cloud constants are found in the .

トークン資格情報と ADAL コンテキストを使用して認証するAuthenticate with token credentials and an ADAL context

トークン資格情報を使用して、より細かく制御する必要がある場合は、Azure Active Directory Authentication Library (ADAL) for Python と SDK ADAL ラッパーを使用します。If you need more control when using token credentials, use the and the SDK ADAL wrapper:

import os, adal
from azure.mgmt.resource import SubscriptionClient
from msrestazure.azure_active_directory import AdalAuthentication
from msrestazure.azure_cloud import AZURE_PUBLIC_CLOUD

# Retrieve the IDs and secret to use with ServicePrincipalCredentials
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
tenant_id = os.environ["AZURE_TENANT_ID"]
client_id = os.environ["AZURE_CLIENT_ID"]
client_secret = os.environ["AZURE_CLIENT_SECRET"]

LOGIN_ENDPOINT = AZURE_PUBLIC_CLOUD.endpoints.active_directory
RESOURCE = AZURE_PUBLIC_CLOUD.endpoints.active_directory_resource_id

context = adal.AuthenticationContext(LOGIN_ENDPOINT + '/' + tenant_id)

credential = AdalAuthentication(context.acquire_token_with_client_credentials,
    RESOURCE, client_id, client_secret)

subscription_client = SubscriptionClient(credential)

subscription = next(subscription_client.subscriptions.list())
print(subscription.subscription_id)

adal ライブラリが必要な場合は、pip install adal を実行します。If you need the adal library, run .

この方法を使用した場合は、Azure パブリック クラウドではなく Azure ソブリン クラウド (国内クラウド) を使用できます。With this method, you can use an rather than the Azure public cloud.

from msrestazure.azure_cloud import AZURE_CHINA_CLOUD

# ...

LOGIN_ENDPOINT = AZURE_CHINA_CLOUD.endpoints.active_directory
RESOURCE = AZURE_CHINA_CLOUD.endpoints.active_directory_resource_id

AZURE_PUBLIC_CLOUD を、msrestazure.azure_cloud ライブラリにある適切なソブリン クラウド定数に置き換えるだけです。Simply replace with the appropriate sovreign cloud constant from the .

CLI ベースの認証 (開発目的のみ)CLI-based authentication (development purposes only)

from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.resource import SubscriptionClient

subscription_client = get_client_from_cli_profile(SubscriptionClient)

subscription = next(subscription_client.subscriptions.list())
print(subscription.subscription_id)

この方法では、Azure CLI コマンド az login でサインインしているユーザーの資格情報を使用してクライアント オブジェクトを作成します。In this method, you create a client object using the credentials of the user signed in with the Azure CLI command .

SDK では既定のサブスクリプション ID が使用されます。または、az account を使用してサブスクリプションを設定することもできます。The SDK uses the default subscription ID, or you can set the subscription using

この方法は、初期段階の実験や開発目的に限定してください。サインイン ユーザーは所有者や管理者の権限を有しているのが一般的であり、別途アクセス許可を取得しなくても、大半のリソースにアクセスできてしまいます。This method should be used only for early experimentation and development purposes because a signed-in user typically has owner or administrator privileges and can access most resources without any additional permissions. 詳細については、DefaultAzureCredential での CLI 資格情報の使用について述べた前出の注意事項を参照してください。For more information, see the previous note about .

非推奨:UserPassCredentials を使用して認証するDeprecated: Authenticate with UserPassCredentials

Azure Active Directory Authentication Library (ADAL) for Python が利用できるようになるまでは、現在は非推奨となっている UserPassCredentials クラスを使用する必要がありました。Before the was available, you has to use the now-deprecated class. このクラスは 2 要素認証をサポートしていないため、今後は使用しないでください。This class doesn't support two-factor authentication and should no longer be used.

関連項目See also