AzureMLTokenAuthentication 类

管理已提交运行的上下文中的身份验证和访问令牌。

提交运行时会生成 Azure 机器学习令牌,并且仅适用于提交运行的代码。 AzureMLTokenAuthentication 类只能在提交的运行的上下文中使用。 返回的令牌不能用于任何 Azure 资源管理器 (ARM) 操作,比如预配计算。 在远程执行程序时,使用用户的专用凭证可能不安全,Azure 机器学习令牌非常有用。

继承
AzureMLTokenAuthentication

构造函数

AzureMLTokenAuthentication(azureml_access_token, expiry_time=None, host=None, subscription_id=None, resource_group_name=None, workspace_name=None, experiment_name=None, run_id=None, user_email=None, experiment_id=None, cloud='AzureCloud')

参数

azureml_access_token
str
必需

提交运行时,将生成 Azure 机器学习令牌,该令牌仅可用于提交的代码。

expiry_time
datetime
默认值: None

Azure 机器学习令牌的过期时间。

host
str
默认值: None
subscription_id
str
默认值: None

提交试验的 Azure 订阅 ID。

resource_group_name
str
默认值: None

提交试验的资源组名称。

workspace_name
str
默认值: None

提交试验的工作区。

experiment_name
str
默认值: None

试验名称。

experiment_id
str
默认值: None

试验 ID。如果提供 experiment_name 将被忽略

run_id
str
默认值: None

运行的 ID。

user_email
str
默认值: None

可选用户邮件。

cloud
str
默认值: AzureCloud

目标云的名称。 可以是“AzureCloud”、“AzureChinaCloud”或“AzureUSGovernment”之一。 如果未指定云,则使用“AzureCloud”。

注解

此类的使用者应调用类方法,该方法 create 创建一个新的对象,或返回具有相同 run_scope (subscription_idresource_group_nameworkspace_nameexperiment_namerun_id) 提供的已注册的实例。

方法

create

创建 AzureMLTokenAuthentication 对象,或返回具有相同 run_scope 的已注册实例。

get_authentication_header

返回 HTTP 授权标头。

授权标头包含用于对服务进行访问授权的用户访问令牌。

set_token

更新 Azure 机器学习访问令牌。

create

创建 AzureMLTokenAuthentication 对象,或返回具有相同 run_scope 的已注册实例。

create(azureml_access_token, expiry_time, host, subscription_id, resource_group_name, workspace_name, experiment_name, run_id, user_email=None, experiment_id=None)

参数

cls
必需

指示类方法。

azureml_access_token
str
必需

提交运行时,将生成 Azure 机器学习令牌,该令牌仅可用于提交的代码。

expiry_time
datetime
必需

Azure 机器学习令牌的过期时间。

host
str
必需
subscription_id
str
必需

提交试验的 Azure 订阅 ID。

resource_group_name
str
必需

提交试验的资源组名称。

workspace_name
str
必需

提交试验的工作区。

experiment_name
str
必需

试验名称。

experiment_id
str
必需

试验 ID。如果提供 experiment_name 将被忽略

run_id
str
默认值: None

运行的 ID。

user_email
str
默认值: None

可选用户邮件。

get_authentication_header

返回 HTTP 授权标头。

授权标头包含用于对服务进行访问授权的用户访问令牌。

get_authentication_header()

返回

返回 HTTP 授权标头。

返回类型

set_token

更新 Azure 机器学习访问令牌。

set_token(token, expiry_time)

参数

token
str
必需

要刷新的标记。

expiry_time
datetime
必需

新的过期时间。

属性

expiry_time

返回 Azure 机器学习令牌的过期时间。

返回

过期时间。

返回类型

token

返回 Azure 机器学习令牌。

返回

Azure 机器学习访问令牌。

返回类型

str

EXPIRATION_THRESHOLD_IN_SECONDS

EXPIRATION_THRESHOLD_IN_SECONDS = 95

REFRESH_INTERVAL_IN_SECONDS

REFRESH_INTERVAL_IN_SECONDS = 30