DEV Community

Avelyn Hyunjeong Choi
Avelyn Hyunjeong Choi

Posted on

Databricks API

NOTE
In the example, whenever the user creates a new entity, it creates a new PAT. In order to create/list/delete the PAT, it needs two following tokens for the service principal: Azure Active Directory(AD) token and Azure Active Directory management endpoint token.

Requirement - The service principal requires the Contributor or Owner role on the Databricks workspace in Azure.

Step 1 - Get Azure AD token for the service principal

https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token#--get-an-azure-ad-access-token-with-the-azure-cli

**NOTE - You can get tenant_id, client_id, and client_secrect from your service principal as below.

Image description

Image description

POST https://login.microsoftonline.com//oauth2/v2.0/token

Image description

Image description

Step 2 - Get Azure AD management endpoint token

POST https://login.microsoftonline.com//oauth2/token

Image description

Now you have two Azure AD tokens (one with Databricks service principal from step1 and another with AD management endpoint from step2)

Step 3 - Create Personal Access Token based on two AD tokens from previous steps

POST /api/2.0/token/create \
-H 'Authorization: Bearer ' \
-H 'X-Databricks-Azure-SP-Management-Token: ' \
-H 'X-Databricks-Azure-Workspace-Resource-Id: /subscriptions//resourceGroups//providers/Microsoft.Databricks/workspaces/'

Image description

Image description

You can now retrieve token_value as well as token_id from above API call. These values will be used to create an external location, catalog and schema and delete PAT that has been already used.

Optionally, you can put request body as below.

Image description

https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/tokens

You can run any Databricks REST API call. Below link provides the REST API endpoint available with Azure Databricks
https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay