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.
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.