AzureCliAuthentication Class

Manages authentication and acquires an access token using the Azure CLI.

To use this class you must have the azure-cli package installed. For a better Azure Notebooks experience, use the InteractiveLoginAuthentication class.

Class Azure Cli Authentication constructor.

Inheritance
AzureCliAuthentication

Constructor

AzureCliAuthentication(cloud=None)

Parameters

cloud
str
default value: None

The name of the target cloud. Can be one of "AzureCloud", "AzureChinaCloud", or "AzureUSGovernment". If no cloud is specified, any configured default from the Azure CLI is used. If no default is found, "AzureCloud" is used.

cloud
str
Required

The name of the target cloud. Can be one of "AzureCloud", "AzureChinaCloud", or "AzureUSGovernment". If no cloud is specified, any configured default from the Azure CLI is used. If no default is found, "AzureCloud" is used.

Remarks

If you have installed azure-cli package, and used az login command to log in to your Azure Subscription, then you can use the AzureCliAuthentication class.


   from azureml.core.authentication import AzureCliAuthentication

   cli_auth = AzureCliAuthentication()

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

   print("Found workspace {} at location {}".format(ws.name, ws.location))

Full sample is available from https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/manage-azureml-service/authentication-in-azureml/authentication-in-azureml.ipynb