次の方法で共有


ServicePrincipalAuthentication クラス

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

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

Class 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"、"AzureChinaCloud"、または "AzureUSGovernment" のいずれかを指定できます。 クラウドが指定されていない場合は、"AzureCloud" が使用されます。

規定値: 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

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