ServicePrincipalAuthentication クラス

ユーザー ID ではなくサービス プリンシパルを使用して認証を管理します。

サービス プリンシパル認証は、CI/CD シナリオなどの自動化されたワークフローに適しています。 この種類の認証では、特定のユーザー ログインから認証プロセスを切り離し、マネージド アクセス制御ができます。

ServicePrincipalAuthentication コンストラクターのクラス。

継承
ServicePrincipalAuthentication

コンストラクター

ServicePrincipalAuthentication(tenant_id, service_principal_id, service_principal_password, cloud='AzureCloud', _enable_caching=True)

パラメーター

tenant_id
str
必須

サービス ID が属している Active Directory のテナント。

service_principal_id
str
必須

サービス プリンシパルの ID。

service_principal_password
str
必須

サービス プリンシパルのパスワード/キー。

cloud
str
既定値: AzureCloud

ターゲット クラウドの名前。 "AzureCloud"、"AzureChinaCloud"、または "AzureUSGovernment" のいずれかを指定できます。 クラウドが指定されていない場合は、"AzureCloud" が使用されます。

tenant_id
str
必須

サービス ID が属している Active Directory のテナント。

service_principal_id
str
必須

サービス プリンシパル ID。

service_principal_password
str
必須

サービス プリンシパルのパスワード/キー。

cloud
str
必須

ターゲット クラウドの名前。 "AzureCloud"、"AzureChinaCloud"、または "AzureUSGovernment" のいずれかを指定できます。 クラウドが指定されていない場合は、"AzureCloud" が使用されます。

_enable_caching
既定値: True

注釈

サービス プリンシパル認証では、Azure Active Directory に "アプリの登録" を作成する必要があります。 まず、クライアント シークレットを生成したうえで、ご自分の機械学習ワークスペースへの "ロール アクセス" をサービス プリンシパルに付与します。 次に、ServicePrincipalAuthentication クラスを使用して、認証フローを管理します。


   import os
   from azureml.core.authentication import ServicePrincipalAuthentication

   svc_pr_password = os.environ.get("AZUREML_PASSWORD")

   svc_pr = ServicePrincipalAuthentication(
       tenant_id="my-tenant-id",
       service_principal_id="my-application-id",
       service_principal_password=svc_pr_password)


   ws = Workspace(
       subscription_id="my-subscription-id",
       resource_group="my-ml-rg",
       workspace_name="my-ml-workspace",
       auth=svc_pr
       )

   print("Found workspace {} at location {}".format(ws.name, ws.location))

完全なサンプルは、https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb から入手できます

サービス プリンシパルを作成し、サービス プリンシパルに機械学習ワークスペースへのアクセスを許可する方法については、サービス プリンシパル認証の設定に関するページを参照してください。