MsiAuthentication 类
使用 Azure Active Directory 中的托管标识管理身份验证。
在 Azure 虚拟机(VM)上使用 Azure ML SDK 时,可以使用 托管标识 (以前称为托管服务标识 - MSI)进行身份验证。 使用托管标识,VM 无需在 Python 代码中存储凭据即可连接到工作区,从而将身份验证过程与任何特定用户登录分离。
MsiAuthentication 构造函数类。
构造函数
MsiAuthentication(cloud=None, **kwargs)
参数
| 名称 | 说明 |
|---|---|
|
cloud
|
目标云的名称。 可以是“AzureCloud”、“AzureChinaCloud”或“AzureUSGovernment”之一。 如果未指定云,将使用 Azure CLI 中配置的任何默认值。 如果未找到默认值,则使用“AzureCloud”。 默认值: None
|
|
identity_config
必需
|
一个映射 |
|
cloud
必需
|
目标云的名称。 可以是“AzureCloud”、“AzureChinaCloud”或“AzureUSGovernment”之一。 如果未指定云,将使用 Azure CLI 中配置的任何默认值。 如果未找到默认值,则使用“AzureCloud”。 |
|
identity_config
必需
|
一个映射 |
注解
以下示例演示如何使用 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))