PowerShell login with an Azure Databricks user account

Follow these steps to use PowerShell 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 PowerShell to run the Connect-AzAccount cmdlet. After you run this cmdlet, follow the on-screen instructions to finish signing in with your account.

    Connect-AzAccount
    

    Note

    If an error message states that the Connect-AzAccount cmdlet is not recognized, install it by running the following cmdlet:

    Install-Module -Name Az -Repository PSGallery -Force
    
  2. Confirm that you are signed in to the correct subscription for your signed-in user. To get the name and ID of your signed-in subscription, as well as the subscription’s related tenant ID, run the following cmdlet:

    Get-AzContext | Select-Object -ExpandProperty Subscription
    

    If you are not sure what the correct subscription should be, you can for example 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 cannot access the Azure Portal, but you have access to your Azure Databricks account console, you can get the correct subscription for an Azure Databricks workspace as follows:

    1. Make a note of the workspace’s programmatic name, which is located next your username in the workspace navigation bar.
    2. Click your username > Manage Account in the workspace navigation bar.
    3. In the sidebar, click Workspaces.
    4. In the Filter workspaces box, enter the workspace’s programmatic name and press Enter.
    5. Click the workspace’s programmatic name in the results list.
    6. Make a note of the Subscription field, which contains the subscription ID.

    If you need to switch to a different subscription, run the Set-AzContext cmdllet, using the -Name or -Subscription parameter to specify the correct subscription name or ID.

    Set-AzContext -Name "<subscription-name>"
    
    # Or ...
    
    Set-AzContext -Subscription <subscription-id>
    

    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 Connect-AzAccount cmdlet 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.

    Connect-AzAccount -Tenant <tenant-id> | Format-Table