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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MK007
Frequent Visitor

Issue accessing zip file from lakehouse using spark job definition

Hi all,

I have a spark job definition which contains a main definition file to programmatically extract a zip file from a lakehouse and extract the contents to a configured destination folder on the same lakehouse. I am using below code for file extraction:

 

 

 

def extract_zip_files(zipfilepath,outputpath):
with zipfile.ZipFile(zipfilepath,'r') as zfile:
zfile.extractall(path=outputpath)

 

 

 

The zip file path (ABFS path), zip file name and destination path (ABFS path) are passed from the command line arguments.

I am encountering below runtime issue while running the spark job:
FileNotFoundError: [Errno 2] No such file or directory: 'abfss://<My workspace ID>@onelake.dfs.fabric.microsoft.com/<My Lakehouse ID>/Files/MyFile.zip'

 

Please let me know if you have any suggestions or if need more information regarding this issue.

3 REPLIES 3
MK007
Frequent Visitor

Thank you @Anonymous for taking a look at this issue. I am trying to extract zip files using spark job defintion instead of a notebook. Within my spark job code, I have tried passing the file paths (ABFS, relative path, file api path) via command line arguments but encountered same error i.e. FileNotFoundError: [Errno 2] No such file or directory. 

Is there an approach to extract zip files within a spark job definition?

Anonymous
Not applicable

Hi @MK007,

I also not find the fact path of files, perhaps you can try to upload the files to environment and use correspond path to extract data: (you can try to use f"{notebookutils.nbResPath} + 'file the relative path'to read data from resource folder)

zipfilepath=f"{notebookutils.nbResPath}/env/Test/test.zip"

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Hi @MK007,

I test with your code in notebook and find the 'zipfilepath' and 'outputpath' parameters should be the api path of files: (you can get it by right-click on the zip file and choose 'copy file api path' option)

import zipfile
zipfilepath="/lakehouse/default/Files/test.zip"
outputpath="/lakehouse/default/Files/Test/"
zfile= zipfile.ZipFile(zipfilepath,'r')
zfile.extractall(path=outputpath)

Result:
1.png

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Fabric Update Carousel

Fabric Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors