AzureMLTokenAuthentication Class
Manages authentication and access tokens in the context of submitted runs.
The Azure Machine Learning token is generated when a run is submitted and is only available to the code that submitted the run. The AzureMLTokenAuthentication class can only be used in the context of the submitted run. The returned token cannot be used against any Azure Resource Manager (ARM) operations like provisioning compute. The Azure Machine Learning token is useful when executing a program remotely where it might be unsafe to use the private credentials of a user.
Authorize users by their Azure ML token.
The Azure ML token is generated when a run is submitted and is only available to the code submitted. The class can only be used in the context of the submitted run. The token cannot be used against any ARM operations like provisioning compute. The Azure ML token is useful when executing a program remotely where it might be unsafe to use the user's private credentials. The consumer of this class should call the class method create which creates a new object or returns a registered instance with the same run_scope (subscription_id, resource_group_name, workspace_name, experiment_name, run_id) provided.
- Inheritance
-
AzureMLTokenAuthentication
Constructor
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')
Parameters
Name | Description |
---|---|
azureml_access_token
Required
|
The Azure ML token is generated when a run is submitted and is only available to the code submitted. |
expiry_time
|
The Azure ML token's expiration time. Default value: None
|
host
|
Default value: None
|
subscription_id
|
The Azure subscription ID where the experiment is submitted. Default value: None
|
resource_group_name
|
The resource group name where the experiment is submitted. Default value: None
|
workspace_name
|
The workspace where the experiment is submitted. Default value: None
|
experiment_name
|
The experiment name. Default value: None
|
experiment_id
|
The experiment id. If provided experiment_name will be ignored Default value: None
|
run_id
|
The ID of the run. Default value: None
|
user_email
|
Optional user email. Default value: None
|
cloud
|
The name of the target cloud. Can be one of "AzureCloud", "AzureChinaCloud", or "AzureUSGovernment". If no cloud is specified, "AzureCloud" is used. Default value: AzureCloud
|
azureml_access_token
Required
|
The Azure ML token is generated when a run is submitted and is only available to the code submitted. |
expiry_time
Required
|
<xref:datetime.Datetime>
The Azure ML token's expiration time. |
host
Required
|
|
subscription_id
Required
|
The Azure subscription ID where the experiment is submitted. |
resource_group_name
Required
|
The resource group name where the experiment is submitted. |
workspace_name
Required
|
The workspace where the experiment is submitted. |
experiment_name
Required
|
The experiment name. |
experiment_id
Required
|
The experiment id. If provided experiment_name will be ignored |
run_id
Required
|
The ID of the run. |
user_email
Required
|
An optional user email. |
cloud
Required
|
The name of the target cloud. Can be one of "AzureCloud", "AzureChinaCloud", or "AzureUSGovernment". If no cloud is specified, "AzureCloud" is used. |
Remarks
Consumers of this class should call the class method create, which creates a new object or
returns a registered instance with the same run_scope (subscription_id
, resource_group_name
,
workspace_name
, experiment_name
, run_id
) provided.
Methods
create |
Create an AzureMLTokenAuthentication object or return a registered instance with the same run_scope. |
get_authentication_header |
Return the HTTP authorization header. The authorization header contains the user access token for access authorization against the service. |
set_token |
Update Azure ML access token. |
create
Create an AzureMLTokenAuthentication object or return a registered instance with the same 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)
Parameters
Name | Description |
---|---|
cls
Required
|
Indicates class method. |
azureml_access_token
Required
|
The Azure ML token is generated when a run is submitted and is only available to the code submitted. |
expiry_time
Required
|
The Azure ML token's expiration time. |
host
Required
|
|
subscription_id
Required
|
The Azure subscription ID where the experiment is submitted. |
resource_group_name
Required
|
The resource group name where the experiment is submitted. |
workspace_name
Required
|
The workspace where the experiment is submitted. |
experiment_name
Required
|
The experiment name. |
experiment_id
|
The experiment id. If provided experiment_name will be ignored Default value: None
|
run_id
Required
|
The ID of the run. |
user_email
|
An optional user email. Default value: None
|
get_authentication_header
Return the HTTP authorization header.
The authorization header contains the user access token for access authorization against the service.
get_authentication_header()
Returns
Type | Description |
---|---|
Returns the HTTP authorization header. |
set_token
Update Azure ML access token.
set_token(token, expiry_time)
Parameters
Name | Description |
---|---|
token
Required
|
The token to refresh. |
expiry_time
Required
|
The new expiration time. |
Attributes
expiry_time
token
EXPIRATION_THRESHOLD_IN_SECONDS
Seconds before expiration that refresh process starts.
EXPIRATION_THRESHOLD_IN_SECONDS = 95
REFRESH_INTERVAL_IN_SECONDS
Seconds before a retry times out.
REFRESH_INTERVAL_IN_SECONDS = 30