ServicePrincipalAuthentication Klas

Hiermee beheert u verificatie met behulp van een service-principal in plaats van een gebruikersidentiteit.

Verificatie van service-principals is geschikt voor geautomatiseerde werkstromen, zoals voor CI/CD-scenario's. Met dit type verificatie wordt het verificatieproces losgekoppeld van elke specifieke gebruikersaanmelding en is beheerd toegangsbeheer mogelijk.

Klasse ServicePrincipalAuthentication-constructor.

Overname
ServicePrincipalAuthentication

Constructor

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

Parameters

tenant_id
str
Vereist

De Active Directory-tenant waartoe de service-id behoort.

service_principal_id
str
Vereist

De id van de service-principal.

service_principal_password
str
Vereist

Het wachtwoord/de sleutel van de service-principal.

cloud
str
standaardwaarde: AzureCloud

De naam van de doelcloud. Dit kan 'AzureCloud', 'AzureChinaCloud' of 'AzureUSGovernment' zijn. Als er geen cloud is opgegeven, wordt 'AzureCloud' gebruikt.

tenant_id
str
Vereist

De Active Directory-tenant waartoe de service-id behoort.

service_principal_id
str
Vereist

De id van de service-principal.

service_principal_password
str
Vereist

Het wachtwoord/de sleutel van de service-principal.

cloud
str
Vereist

De naam van de doelcloud. Dit kan 'AzureCloud', 'AzureChinaCloud' of 'AzureUSGovernment' zijn. Als er geen cloud is opgegeven, wordt 'AzureCloud' gebruikt.

_enable_caching
standaardwaarde: True

Opmerkingen

Voor verificatie met de service-principal moet u een app-registratie maken in Azure Active Directory. Eerst genereert u een clientgeheim en vervolgens verleent u uw service-principal roltoegang tot uw machine learning-werkruimte. Vervolgens gebruikt u de klasse ServicePrincipalAuthentication om uw verificatiestroom te beheren.


   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))

Het volledige voorbeeld is beschikbaar via https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb

Zie Verificatie van service-principals instellen voor meer informatie over het maken van een service-principal en het toestaan van de service-principal om toegang te krijgen tot een machine learning-werkruimte.