ServicePrincipalAuthentication Classe
Gère l’authentification à l’aide d’un principal de service au lieu d’une identité d’utilisateur.
L’authentification du principal du service est adaptée aux flux de travail automatisés comme pour les scénarios CI/CD. Ce type d’authentification dissocie le processus d’authentification de toute connexion utilisateur spécifique et permet un contrôle d’accès géré.
Constructeur ServicePrincipalAuthentication de classe.
- Héritage
-
ServicePrincipalAuthentication
Constructeur
ServicePrincipalAuthentication(tenant_id, service_principal_id, service_principal_password, cloud='AzureCloud', _enable_caching=True)
Paramètres
- cloud
- str
Nom du cloud cible. Il peut s’agir de « AzureCloud », « AzureChinaCloud » ou « AzureUSGovernment ». Si aucun cloud n’est spécifié, « AzureCloud » est utilisé.
- cloud
- str
Nom du cloud cible. Il peut s’agir de « AzureCloud », « AzureChinaCloud » ou « AzureUSGovernment ». Si aucun cloud n’est spécifié, « AzureCloud » est utilisé.
- _enable_caching
Remarques
Pour permettre l’authentification du principal de service, créez une inscription d’application dans Azure Active Directory. Commencez par générer un secret client, puis accordez au principal de service un accès en fonction du rôle à votre espace de travail Machine Learning. Ensuite, vous utilisez la classe ServicePrincipalAuthentication pour gérer votre flux d’authentification.
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))
Un exemple complet est disponible à l’adresse https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb
Pour en savoir plus sur la création d’un principal de service et autoriser le principal du service à accéder à un espace de travail Machine Learning, consultez Configurer l’authentification du principal de service.
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour