Azure CLI login with an Azure Databricks user account

Follow these steps to use the Azure CLI to log in to Azure Databricks with an Azure Databricks user account. For information about Azure Databricks user accounts, see Manage users.

  1. Begin signing in to Azure by using the Azure CLI to run the az login command. Use the --output option to display the command’s output in a different format (in this case, a table instead of JSON) for better readability. After you run this command, follow the on-screen instructions to finish signing in with your account.

    az login --output table
    
  2. Confirm that you are signed in to the correct subscription for your signed-in user. To do this, in the output of the az login command, look for the table row where IsDefault is set to True. The subscription’s Name indicates the current subscription.

    If you are not sure what the correct subscription should be, see Get subscription and tenant IDs in the Azure portal. Or, try running the az databricks workspace list command later in this step.

    If you need to switch to a different subscription, run the az account set command, using the --name or --subscription option to specify the correct subscription name or ID.

    az account set --name "<subscription-name>"
    
    # Or ...
    
    az account set --subscription <subscription-id>
    

    You can get the subscription ID for an Azure Databricks workspace by clicking your username > Azure Portal in the workspace navigation bar. On the Azure Databricks workspace resource page that appears, click Overview in the sidebar. Then look for the Subscription ID field, which contains the subscription ID.

    If you do not have access to the Azure Portal, you can get the subscription ID for an Azure Databricks workspace by running the az databricks workspace list command, using the --query and --output options to narrow down the results. Replace adb-0000000000000000.0.azuredatabricks.net with the name of your workspace instance, not including the https://. In this example, the 00000000-0000-0000-0000-000000000000 after /subscriptions/ in the output is the subscription ID.

    az databricks workspace list --query "[?workspaceUrl==\`adb-0000000000000000.0.azuredatabricks.net\`].{id:id}" --output tsv
    
    # /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.Databricks/workspaces/my-ws
    

    If the following message displays, you are signed in to the wrong tenant: The subscription of '<subscription-id>' doesn't exist in cloud 'AzureCloud'. To sign in to the correct tenant, you must run the az login command again, using the --tenant option to specify the correct tenant ID.

    You can get the tenant ID for an Azure Databricks workspace by running the command curl -v <per-workspace-URL>/aad/auth and looking in the output < location: https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000, where 00000000-0000-0000-0000-000000000000 is the tenant ID. See also Get subscription and tenant IDs in the Azure portal.

    az login --tenant <tenant-id> --output table