Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Follow these steps to use the Azure CLI to log in to Azure Databricks with a Microsoft Entra ID service principal. For information about Azure Databricks service principals, see Service principals.
Gather the following information:
Parameter Description Tenant IDThe Directory (tenant) IDfor the related application registered in Microsoft Entra ID.Client IDThe Application (client) IDfor the related application registered in Microsoft Entra ID.Client secretThe Valueof the client secret for the related application registered in Microsoft Entra ID.Get the correct Azure subscription ID for the Microsoft Entra ID service principal, if you do not already know this ID, by doing one of the following:
In your Azure Databricks workspace's top navigation bar, click your username and then click Azure Portal. 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.
Use the Azure CLI to run the az databricks workspace list command, using the
--queryand-oor--outputoptions to narrow down the results. Replaceadb-0000000000000000.0.databricks.azure.cnwith the name of your workspace instance, not including thehttps://. In this example, the00000000-0000-0000-0000-000000000000after/subscriptions/in the output is the subscription ID.az databricks workspace list --query "[?workspaceUrl==\`adb-0000000000000000.0.databricks.azure.cn\`].{id:id}" -o tsv # /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-rg/providers/Microsoft.Databricks/workspaces/my-wsIf 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 theaz logincommand again, using the-tor--tenantoption 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/authand looking in the output< location: https://login.chinacloudapi.cn/00000000-0000-0000-0000-000000000000, where00000000-0000-0000-0000-000000000000is the tenant ID. See also Get subscription and tenant IDs in the Azure portal.az cloud set -n AzureChinaCloud az login -t <tenant-id> # az cloud set -n AzureCloud //means return to Public Azure.
After you have the correct Azure tenant ID, client ID, client secret, and subscription ID for your Microsoft Entra ID service principal, sign in to Azure by using the Azure CLI to run the az login command. Use the
--service-principaloption along with specifying the values for the parameters ofTenant ID(Directory (tenant) ID),Client ID(Application (client) ID), andClient secret(Value) for the related application registered in Microsoft Entra ID.az cloud set -n AzureChinaCloud # az cloud set -n AzureCloud //means return to Public Azure. az login \ --service-principal \ -t <Tenant-ID> \ -u <Client-ID> \ -p <Client-secret>Confirm that you are signed in to the correct subscription for your signed-in Microsoft Entra ID service principal. To do this, run the az account set command, using the
-sor--subscriptionoption to specify the correct subscription ID.az account set -s <subscription-id>