The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
Please suggest code to download files from Fabric lakehouse to my local computer. I want to run this code in my fabric notebook.
@SriThiruLet's break down your request into parts.
1. Download files from Fabric lakehouse to my local computer.
Conceptually speaking, Fabric Lakehouse file storage is very similar to Azure ADLS storage and is available via similar API. So, to download a file from a Fabric Lakehouse is the same as download a file from another Azure ADLS storage account using an API. However, although the file storage in Fabric is provided via a Lakehouse explorer, the Lakehouse API cannot be used to access files. Instead, you sould be using OneLake API as described here How do I connect to OneLake? - Microsoft Fabric | Microsoft Learn. You can find a lot of code examples of working with OneLake files via API in different languages. If you prefer Python, this is a Microsoft provided documentation Access OneLake with Python - Microsoft Fabric | Microsoft Learn.
2. Run this code in my Fabric notebook.
This is not a correctly phrased request in the context of the #1 because the code that downloads a file should be executed on a remote computer that downloads a file form Fabric. Such code cannot be executed in Fabric because Fabric cannot have access to your remote computer to save the file there. Your code runs on a remote computer and executes a pull operation from Fabric as opposed to when Fabric pushes a file somewhere (which generally can be done, just not in the way you described).
Hope, this explanation helps clarify your situation.
As for the code, you don't necessarily need to write a code to download a file. The easiest way is to install a OneLake explorer for Windows Access Fabric data locally with OneLake file explorer - Microsoft Fabric | Microsoft Learn. Because Fabric API communicates via HTTP you could even use a utility like curl, to download a file from Fabric Lakehouse.
Another alternative to dowload a file is to use Fabric CLI. You can find an example here Onelake examples | fabric-cli.
Hi @SriThiru ,
May I ask if your problem has been solved. If not you may consider using Python in your Fabric notebook like below:
import requests
file_url = 'https://fabric-lakehouse-url/path/to/your/file'
local_path = 'path/to/save/file'
response = requests.get(file_url)
with open(local_path, 'wb') as file:
file.write(response.content)
print(f'File downloaded and saved to {local_path}')
Best Regards,
Ada Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Have you tried the OneLake app? It works much like OneDrive.
Download Microsoft OneLake file explorer for Windows from Official Microsoft Download Center
I used to use that APP, but after i had to rebuild my laptop and a reinstall of the APP, you can no longer see your lakehouse, and its files pretty unhappy with that because as a dev it was a handy tool to have👎 , already tried reinstalling the app again but no dice
Have you tried right-clicking the OneLake folder in Windows Explorer and then "sync from OneLake" or something similar. That usually does it for me.
it seems to have woken up overnight 😁
The OneLake app is blocked in my environment (and no-one has been able to discover why); I was hoping there'd be an API call instead.
Hi @abm_chris ,
Yes I tried the app.
But I want to do this programatically, can you please suggest the code.
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
1 |
User | Count |
---|---|
16 | |
15 | |
11 | |
6 | |
6 |