How can I enable the 'SHAREPOINT' type connection in Azure Databricks?

Power BI Test User 2 0 Reputation points
2025-03-05T02:35:40.4366667+00:00

I tried to connect SharePoint using Azure Databricks Lakehouse Federation.

First, I select Connection type "Microsoft SharePoint" to create a Lakehouse Federation.User's image Next, I input authentication info and sign in with Microsoft SharePoint.User's image Then, I am successfully authorized but fail to create connectionUser's image

How can I enable the 'SHAREPOINT' type connection in Azure Databricks?

Any settings needed?

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,368 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rakesh Govindula 175 Reputation points Microsoft External Staff
    2025-03-06T15:44:16.3133333+00:00

    Hello @Power BI Test User 2,

    As per this MS Documentation,

    Currently, Sharepoint is not support as a Data source in the Lakehouse Federation of Azure Databricks.

    You can try the below workaround if there is a need to achieve this using Databricks.

    Using Microsoft App registration and the Microsoft Graph API:

    First create an App registration and create a secret. Store the details like client id, tenant id and secret.

    Grant Files.Read.All api permission to the application with Application permission type.

    enter image description here

    Generate the access token using the below code:

    
    auth_url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
    
    auth_data = {
    
        "grant_type": "client_credentials",
    
        "client_id": client_id,
    
        "client_secret": client_secret,
    
        "scope": "https://graph.microsoft.com/.default"
    
    }
    
    auth_response = requests.post(auth_url, data=auth_data)
    
    access_token = auth_response.json().get("access_token")
    
    

    Next get your site id using below code.

    
    headers = {"Authorization": f"Bearer {access_token}"}
    
    site_res = requests.get("https://graph.microsoft.com/v1.0/sites/root:/sites/<site_name>",headers=headers)
    
    site_id = site_res.json()['id']
    
    

    Now, use the below code to get the file stored in dbfs.

    
    download_url = f"https://graph.microsoft.com/v1.0/sites/{site_id}/drive/root:/filename.xlsx:/content"
    
    file_response = requests.get(download_url, headers=headers)
    
    print(file_response.status_code)
    
    if file_response.status_code == 200:
    
        file_path = "/dbfs/filename.xlsx"
    
        with open(file_path, "wb") as f:
    
            f.write(file_response.content)
    
        print(f"file was created")
    
    else:
    
        print(file_response.status_code)
    
    

    Now, you can read this file from DBFS as per your requirement.

    Hope this helps. Do let us know if you have any further queries.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.