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} ,例如 {"client_id": "..."} 。 請查看裝載環境的檔,以瞭解其預期值。

cloud
str
必要

目標雲端的名稱。 可以是其中一個 「AzureCloud」、「AzureChinaCloud」 或 「AzureUSGovernment」。 如果未指定任何雲端,則會使用 Azure CLI 中任何已設定的預設值。 如果找不到預設值,則會使用 「AzureCloud」。

identity_config
Mapping[str, str]
必要

指定使用者指派身分識別的對應 {parameter_name: value} ,例如 {"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