Authentication setup for the Databricks extension for Visual Studio Code

This article describes how to set up authentication between the Databricks extension for Visual Studio Code and your Azure Databricks workspace if you haven't already configured the extension through project setup. See What is the Databricks extension for Visual Studio Code?.

The Databricks extension for Visual Studio Code implements portions of the Databricks client unified authentication standard, which enables you to configure Azure Databricks authentication once and then use that configuration across multiple Azure Databricks tools and SDKs without further authentication configuration changes.

If you are using Azure Databricks personal access token authentication, or MS Entra service principal authentication, see Set up authentication with a configuration profile. For Azure CLI authentication, see Set up Azure CLI authentication.

Note

The Databricks extension for Visual Studio Code does not support authentication using Azure managed identities (formerly Azure Managed Service Identities (MSI)), but Databricks Connect used without the Databricks extension for Visual Studio Code does. To install Databricks Connect, see Use Visual Studio Code with Databricks Connect for Python.

Set up authentication with a configuration profile

The following instructions assume that you have already set up an Azure Databricks configuration profile with the required fields for your Azure Databricks authentication type. To create a profile, see Azure Databricks configuration profiles. To configure settings for the profile, see the Profile tab or section for your authentication type in Authenticate access to Azure Databricks resources.

To select the configuration profile that you want the extension to use, with your project and the extension open, do the following:

  1. In the Configuration view, click Auth Type, and then click the gear (Sign in to Databricks workspace) icon.

    Sign in to Databricks workspace

  2. In the Command Palette, select your target Azure Databricks configuration profile in the list.

    Tip

    The target workspace host can be changed later by modifying the target workspace setting in the databricks.yml configuration file associated with the project. See Databricks Asset Bundle configuration.

If you do not have a configuration profile, you can create one that authenticates by using an Azure Databricks personal access token for example, as follows:

  1. With your project and the extension open, in the Configuration view, click Auth Type or Login to Databricks, and then click the gear (Sign in to Databricks workspace) icon.

    Sign in to Databricks workspace

  2. In the Command Palette, select Personal Access Token.

  3. Complete the on-screen prompts to do the following:

    1. Enter some name for the associated Azure Databricks authentication profile.
    2. Generate the personal access token in your Azure Databricks workspace and then copy the token's value.
    3. Return to the extension and enter the copied token's value.

The extension creates a folder in your project named .databricks with a file named databricks.env, if it does not already exist. This file contains the workspace host that you entered, along with other Azure Databricks configuration details used by the Databricks extension for Visual Studio Code.

The extension also adds a hidden .gitignore file to the project if the file does not exist or if an existing .gitignore cannot be found in any parent folders. If a new .gitignore file is created, the extension adds a .databricks/ entry to this new file. If the extension finds an existing .gitignore file, it adds a .databricks/ entry to the existing file.

Set up Azure CLI authentication

Azure Databricks supports authentication with the Azure CLI installed locally. This enables you to generate short-lived (one hour) Microsoft Entra ID tokens, which eliminates the risk of accidentally exposing longer-lived tokens such as Azure Databricks personal access tokens through version control checkins or other means.

With your project and the extension opened, and the Azure CLI installed locally, do the following:

  1. In the Configuration view, click Configure Databricks.

    Note

    If Configure Databricks is not visible, click the gear (Configure workspace) icon next to Configuration instead.

    Gear icon to configure workspace settings 1

  2. In the Command Palette, for Databricks Host, enter your per-workspace URL, for example https://adb-1234567890123456.7.databricks.azure.cn. Then press Enter.

  3. Select Azure CLI.