Connect and authenticate the Databricks IDE extension

This article describes how to sign in to your Azure Databricks workspace from the Databricks IDE extension. See Databricks IDE extension.

The extension signs in with Databricks configuration profiles, as defined by Databricks unified authentication. A profile that you create in the extension also works with the Databricks CLI and the Databricks SDKs, and the extension can use profiles that you created with those tools. The extension refreshes access tokens for you.

Databricks recommends OAuth user-to-machine (U2M) authorization. See Sign in with OAuth.

Otherwise, if you use OAuth machine-to-machine (M2M) authorization or another existing profile, see Sign in with an existing configuration profile. To create a profile with a personal access token, see Sign in with a personal access token. For Authenticate with the Azure CLI, see Sign in with the Azure CLI.

Note

The Databricks IDE extension version 3 doesn't support other authentication types, such as Microsoft Entra ID service principals, Azure managed identities, or OAuth token federation. A profile that uses one of them can't connect.

To use these authentication types with Databricks Connect, use Databricks Connect without the extension. See Install Databricks Connect for Python.

Sign in with OAuth

To sign in to a workspace with OAuth:

  1. On the sidebar, click the Databricks icon.

  2. In the Connection view, click Sign in to Databricks, or click the Workspace connection row if the view shows it. You can also run Databricks: Sign in to Databricks workspace from the Command Palette.

    Connection view with the Sign in to Databricks button

  3. For Databricks Host, select your workspace or enter your per-workspace URL, for example https://adb-1234567890123456.7.azuredatabricks.net. The list shows the workspaces of your existing configuration profiles.

    If you don't know your workspace URL, select Sign in via login.databricks.com instead, and choose your workspace in your web browser.

  4. For Select authentication method, select OAuth.

    If the list already has a profile for this workspace, you can select it instead. See Sign in with an existing configuration profile.

  5. Enter a name for the profile.

    The first time you sign in on a machine that has no profiles, the extension doesn't ask for a name. It names the profile DEFAULT, or uses the workspace.profile setting of your bundle target if the target sets one.

  6. Complete the sign-in in your web browser. If prompted, allow all-apis access.

  7. Return to Visual Studio Code.

When you are signed in, the Workspace connection row in the Connection view shows the profile name. Expand the row to see the host, workspace, user, and authentication type.

If your workspace URL also serves your account and its other workspaces, the extension asks you to choose a workspace before the browser opens. Personal access tokens aren't offered for these hosts. If a profile is signed in to the account but doesn't name a workspace, the Workspace connection row shows Signed in to the account, not a workspace. Click Select a workspace on the row to choose one.

Note

The Databricks CLI uses the DEFAULT profile for databricks commands that you run in a terminal, unless you set DATABRICKS_CONFIG_PROFILE or DATABRICKS_HOST, or your configuration file names another default profile.

Sign in with an existing configuration profile

You can sign in with any configuration profile for a supported authentication type, including profiles that you created with the Databricks CLI. To create a profile, see Azure Databricks configuration profiles. To configure the profile's fields, see the documentation for your authentication type.

To sign in with an existing profile:

  1. In the Connection view, click Sign in to Databricks, or click the Workspace connection row if the view shows it.
  2. For Databricks Host, select the workspace that the profile connects to.
  3. For Select authentication method, select the profile.

To create or edit other profiles, select Edit Databricks profiles for Select authentication method. The extension opens your .databrickscfg file. To use a different configuration file, set Override Databricks Config File (databricks.overrideDatabricksConfigFile). See Settings for the Databricks IDE extension.

Sign in with a personal access token

Important

Where possible, Databricks recommends using OAuth instead of personal access tokens (PATs) for user account authentication because OAuth provides stronger security. See Sign in with OAuth.

To create a profile that uses a personal access token:

  1. In the Connection view, click Sign in to Databricks, or click the Workspace connection row if the view shows it.

  2. For Databricks Host, select your workspace or enter your per-workspace URL, for example https://adb-1234567890123456.7.azuredatabricks.net.

  3. For Select authentication method, select Personal Access Token.

  4. Enter a name for the profile.

    The first time you sign in on a machine that has no profiles, the extension doesn't ask for a name. It names the profile DEFAULT, or uses the workspace.profile setting of your bundle target if the target sets one.

  5. Generate a personal access token in your workspace, and copy its value. See Authenticate with Azure Databricks personal access tokens (legacy).

  6. Return to the extension, enter the token, and then press Enter.

Switch workspaces or profiles

How you switch depends on whether a bundle project is open:

  • No bundle project open: In the Connection view, click Switch workspace on the Workspace connection row, and then select another workspace or profile.
  • Bundle project open: The bundle target decides the workspace. To use another profile for the same workspace, click Switch profile on the Workspace connection row. To use another workspace, select another target, or change the target's workspace.host setting in databricks.yml. See Change the target deployment workspace.

When you select a target in another workspace, the extension switches to a profile for that workspace and shows which profile it chose. If more than one profile matches, the Workspace connection row shows Select a profile.

To sign out, click Sign out on the Workspace connection row, or run Databricks: Sign out from the Command Palette. Signing out disconnects the extension from the workspace. It doesn't delete the profile from your configuration file.

If your OAuth session expires, the Workspace connection row shows Can't connect. Click Sign in again on the row to sign in in your web browser.

Sign in with the Azure CLI

Azure Databricks supports authentication with the Azure CLI installed locally. The Azure CLI generates short-lived (one hour) Microsoft Entra ID tokens. This reduces the risk of exposing longer-lived tokens, such as Azure Databricks personal access tokens, through version control check-ins or other means.

To sign in with the Azure CLI:

  1. Install the Azure CLI, and then run az login.

  2. Add a profile with auth_type = azure-cli to your .databrickscfg file. To open the file from the extension, run Databricks: Open Databricks configuration file from the Command Palette.

    [my-azure-cli]
    host      = https://adb-1234567890123456.7.azuredatabricks.net
    auth_type = azure-cli
    

    The extension needs the auth_type = azure-cli setting. Without it, the extension signs in to a profile that has only a host with OAuth. To use a specific Microsoft Entra ID tenant, also add azure_tenant_id.

  3. In the Connection view, click Sign in to Databricks, or click the Workspace connection row if the view shows it.

  4. For Databricks Host, select your workspace.

  5. For Select authentication method, select the profile.

Unity Gateway sign-in

Databricks models in Visual Studio Code Chat use a separate sign-in to Unity Gateway. It appears as the Unity Gateway connection row in the Connection view, and it can use a different workspace from your project. The first time you sign in to a workspace, Unity Gateway signs in to the same workspace. You can switch or sign out of Unity Gateway separately.