Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at the 2025 Microsoft Fabric Community Conference. March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for $400 discount. Register now

Reply
AdarshPanasri
Helper I
Helper I

How to read/write to Onelake lakehouse using function app

Hello Everyone, I want to read files from Onelake lakehouse in my function app or local setup, can someone help me connect to the lakehouse and get the files, also I would want to write some data back to the lakehouse.

 

I know we can refer to the storage similar to the ADLS gen2, but how do I authenticate my client to get the files from the Lakehouse, what permissions are needed to do so ?

1 ACCEPTED SOLUTION
v-huijiey-msft
Community Support
Community Support

Hi @AdarshPanasri ,

 

To connect to OneLake Lakehouse and perform read/write operations, you can follow the steps below:

 

You can use Microsoft Entra ID to authenticate your client.

 

Here is a Python example:

 

First, run the following statement to install the required packages.

pip install azure-identity azure-storage-file-datalake

 

To authenticate, replace <your-tenant-id>, <your-client-id>, and <your-client-secret> with your actual tenant ID, client ID, and client secret, respectively.

from azure.identity import ClientSecretCredential
from azure.storage.filedatalake import DataLakeServiceClient

tenant_id = "<your-tenant-id>"
client_id = "<your-client-id>"
client_secret = "<your-client-secret>"

credential = ClientSecretCredential(tenant_id, client_id, client_secret)
service_client = DataLakeServiceClient(account_url=https://<your-account-name>.dfs.core.windows.net, credential=credential)

 

Regarding identity verification, this article may be helpful to you:

How to use service principal authentication to access Microsoft Fabric's OneLake (dataroots.io)

 

Regarding your question about permissions, there are two aspects.

 

Read permissions:

  • ReadData permissions on SQL endpoints to access data without SQL policies.
  • ReadAll permissions for all data in the lake warehouse using Apache Spark.

 

Write permissions:

  • You need to be assigned one of the following roles in your workspace: Admin, Member, or Contributor.

If you have any questions or need further help, feel free to contact me!

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

1 REPLY 1
v-huijiey-msft
Community Support
Community Support

Hi @AdarshPanasri ,

 

To connect to OneLake Lakehouse and perform read/write operations, you can follow the steps below:

 

You can use Microsoft Entra ID to authenticate your client.

 

Here is a Python example:

 

First, run the following statement to install the required packages.

pip install azure-identity azure-storage-file-datalake

 

To authenticate, replace <your-tenant-id>, <your-client-id>, and <your-client-secret> with your actual tenant ID, client ID, and client secret, respectively.

from azure.identity import ClientSecretCredential
from azure.storage.filedatalake import DataLakeServiceClient

tenant_id = "<your-tenant-id>"
client_id = "<your-client-id>"
client_secret = "<your-client-secret>"

credential = ClientSecretCredential(tenant_id, client_id, client_secret)
service_client = DataLakeServiceClient(account_url=https://<your-account-name>.dfs.core.windows.net, credential=credential)

 

Regarding identity verification, this article may be helpful to you:

How to use service principal authentication to access Microsoft Fabric's OneLake (dataroots.io)

 

Regarding your question about permissions, there are two aspects.

 

Read permissions:

  • ReadData permissions on SQL endpoints to access data without SQL policies.
  • ReadAll permissions for all data in the lake warehouse using Apache Spark.

 

Write permissions:

  • You need to be assigned one of the following roles in your workspace: Admin, Member, or Contributor.

If you have any questions or need further help, feel free to contact me!

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebFBC_Carousel

Fabric Monthly Update - February 2025

Check out the February 2025 Fabric update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.