Rename the folder dynamically in Azure Data Factory pipeline - azure-data-factory

how to rename folders when transferring from one container to anther container by using dynamically in azure data factory
I want to modify the folder name by dynamically

I tried to dynamically rename the folder in ADF pipeline while copying. Below is the process.
Lookup activity is taken with the dataset containing old_name and new_name of the folder.
In For-each, Copy data is taken. In source dataset, folder name is given dynamically.
Wildcard File Path: container2/#{item().old_name}/*
In sink dataset, new folder name is given dynamically in another container.
File Path: container1/#{item().new_name}/
Files are copied to new container with new folder names.

Related

Azure DataFactory create folder dynamically and create json file

I have a scenario in which, through datafactory a folder must be created dynamically, which implies that its name must be generated dynamically, this folder is created inside a root folder, once this folder is created, then create a couple of Json files in it, but I can't figure out how to do it.
The idea is to generate the json files from sql server and through datafactory consult these files and load them in the folder once it is created.
I think it can be done by copy activity but i am literally stuck and i don't know what to do
any ideas?...
There is no need to create a folder separately. We can specify folder name in directory field of Sink dataset. If the specified folder does not exist, a folder will be created, and file will be copied to it.
Please follow below steps:
Step1: add source to Azure data factory
Step2: Create Set variable Add name and Value.
Step3: Go to sink add Storage account and select Json format.
Step4: Open Json file -> Add parameter name and string type -> connection add dynamic Contant.
Step5: Go to Sink, you will find Parameter name and add dynamic content of Set variable.
This is the output of Storage account.
Note: Edit the value for set variable activity to give required dynamic name ( I used 'output' as value for demonstration) for your
output folder.

How to delete all files in root of File system with Delete Activity of Data Factory?

I have on-prem file System Data set with pathpath "Z:\ProjectX"
It has contains files like Z:\ProjectX\myfile1.json
I would like to delete all json files in "Z:\ProjectX".
I wonder how to do? What value should be set to Folder?
In source settings, select the File path type as Wildcard file path and provide the Wildcard file name as ‘*.json’ to delete all the files of type JSON.

Iterate through folders in azure data factory

I've a requirement like: I've three folders in azure blob container, and inside those three folders have three zip files and the zip files contains respective source files (*.csv) with same structure. I want to loop through the each folders and extract each of the zip files into an output folder then I want to load all the three csv files into target sql table. How can I achieve this by using azure data factory?
Azure storage account
productblob (blob container)
Folder1 >> product1.zip >> product1.csv
Folder2 >> product2.zip >> product2.csv
Folder3 >> product3.zip >> product3.csv
I've already tried to loop through the folders and got the output in Foreach iterator activity but unable to extract the zip files.
After looping to ForEcah activity, you could follow the following steps:
Select a binary dataset and give file path as Foreach output(by creating a parameter in Dataset and in Source defining the value to this parameter). Select compression type as ZipDeflate.
In the sink, select the path where you want to save the unzipped files. (Select Flatten hierarchy in Sink if you want only the files.)

How to copy CSV file from blob container to another blob container with Azure Data Factory?

I would like to copy any file in Blob container to another Blob container. No transformation is needed. How to do it?
However I get validate error:
Copy data1:
Dataset yellow_tripdata_2020_1 location is a folder, the wildcard file name is required for
Copy data1
As the error states: the wildcard file name is required for Copy data1.
On your data source, in the file field, you should enter a pattern that matches the files you want to copy. So *.* if you want to copy all the files, and something like *.csv if you only want to copy over CSV files.

Copy activity with simultaneous renaming of a file. From blob to blob

I have a "copy data" activity in Azure Data Factory. I want to copy .csv files from blob container X to Blob container Y. I don't need to change the content of the files in any way, but I want to add a timestamp to the name, e.g. rename it. However, I get the following error "Binary copy does not support copying from folder to file". Both the source and the sink are set up as binary.
If you want to copy the files and rename them, you pipeline should like this:
Create a Get Metadata active to get the file list(dataset Binary1):
Create For Each active to copy the each file:#activity('Get Metadata1').output.childItems:
Foreach inner active, create a copy active with source dataset
Binary2(same with Binary2) with dataset parameter to specify the source file:
Copy active sink setting, create the sink Binary3 also with
parameter to rename the files:
#concat(split(item().name,'.')[0],utcnow(),'.',split(item().name,'.')[1]):
Run the pipeline and check the output:
Note: The example I made just copy the files to the same container but with new name.