Hi @vikranth-0706
Thank you for using Microsoft Q&A platform and thanks for posting your query here.
It seems that you are trying to use Azure Data Factory (ADF) to unzip compressed files in Blob storage, but you are encountering an issue when dealing with nested zip files. The current behavior of the Copy Data activity is to extract nested zip files individually, creating folders named after each nested archive and placing the uncompressed content inside them. However, you want to preserve the nested zip files within a designated folder named after the main archive.
Unfortunately, ADF does not have a built-in feature to handle nested zip extraction in one go.
Since your root zip file contains zip files only in a sub-folder, you can try the following workaround. This approach creates the needed zip files from the unzipped folders and deletes those folders.
After the copy activity, use a 'Get Metadata' activity with a Binary dataset and set the 'ChildItems' field. The Binary dataset path should be the target unzipped folder (in my case, it's 'zipsoutout/mainzip.zip') and don't specify a compression type.
This will list all the folder and file names. Use the filter activity to remove unzipped folder names from the list. Folders with '.zip' at the end are the unzipped ones.
Use the expressions below for the items and condition in the filter activity.
Items : @activity('Get Metadata1').output.childItems
condition : @endswith(item().name, '.zip')
Now, pass the output array from the Filter activity @activity('Filter1').output.value to the For-Each activity.
Inside the For-Each, use a Copy activity to zip the folders. Use the same dataset from the previous Get Metadata activity as the source for the Copy activity with the configurations below.
@concat('mainzip.zip/',item().name)
Create a new Binary dataset with same folder path but for the file path, create a dataset parameter and use that in the file name. Give the required Compression type as well.
Use this dataset as the sink in the copy activity and set the dataset parameter to @item().name in the copy activity.
This copy activity will create the zip file you need. To remove the existing unzipped folders, use a Delete activity, which will need a Binary dataset.
Create a dataset parameter and use it in the folder name like this:
In the delete activity, use the below expression as the value for the above parameter and follow the below configurations.
@concat('mainzip.zip/',item().name)
This will delete everything inside the unzipped folders. Since you're using Blob storage, the empty folders will be deleted automatically.
Now, run the pipeline in debug mode, and it will create the needed inner zip files.
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.