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

서비스 주체를 만들고 서비스 주체가 Machine Learning 작업 영역에 액세스하도록 허용하는 방법에 관한 자세한 내용은 Set up service principal authentication(서비스 주체 인증 설정)을 참조하세요.