MsiAuthentication 类

使用 Azure Active Directory 中的托管标识管理身份验证。

在 Azure 虚拟机 (VM) 上使用 Azure ML SDK 时,可以使用托管标识(以前称为托管服务标识 - MSI)进行身份验证。 使用托管标识允许 VM 连接到工作区,而无需在 Python 代码中存储凭据,从而将身份验证过程与任何特定的用户登录分离。

类 MsiAuthentication 构造函数。

继承
MsiAuthentication

构造函数

MsiAuthentication(cloud=None, **kwargs)

参数

cloud
str
默认值: None

目标云的名称。 可以是“AzureCloud”、“AzureChinaCloud”或“AzureUSGovernment”之一。 如未指定云,则使用 Azure CLI 中任何配置的默认值。 如果未找到默认值,则使用“AzureCloud”。

identity_config
Mapping[str, str]
必需

一个映射 {parameter_name: value},按其对象或资源 ID(如 {"client_id": "..."})指定用户分配的标识。 请查看托管环境的文档,了解其预期值。

cloud
str
必需

目标云的名称。 可以是“AzureCloud”、“AzureChinaCloud”或“AzureUSGovernment”之一。 如未指定云,则使用 Azure CLI 中任何配置的默认值。 如果未找到默认值,则使用“AzureCloud”。

identity_config
Mapping[str, str]
必需

一个映射 {parameter_name: value},按其对象或资源 ID(如 {"client_id": "..."})指定用户分配的标识。 请查看托管环境的文档,了解其预期值。

注解

以下示例演示了如何使用 MsiAuthentication。


   from azureml.core.authentication import MsiAuthentication

   msi_auth = MsiAuthentication()

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

   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 获取