redwolf_cr7
redwolf_cr7

Reputation: 2047

Azure Data Factory: How to retain the file name in the sink through a copy activity

I'm trying to copy a file from SFTP to Blob Storage container. However, after the activity the filename in the Storage container seems completely random and different from that of the source file. How can I persist the file name?

I tried to follow this similar post , but in my case, i dont see the option of 'Dataset Properties' at all, neither for sink nor for source.

What am i missing?

enter image description here

enter image description here

Upvotes: 1

Views: 1061

Answers (1)

Rakesh Govindula
Rakesh Govindula

Reputation: 11549

but in my case, i dont see the option of 'Dataset Properties' at all, neither for sink nor for source

The dataset properties mean the dataset parameters. To see those, first you need to create dataset parameters in both source and sink datasets. As you want your file name to be dynamic, you need to give those parameters in the file name section of the datasets.

Create string type parameter without any default value like below.

Source dataset:

enter image description here

Now, give this in the dataset file name as @dataset().<parameter_name>. Give your source folder path.

enter image description here

To get the child file names from the source folder using Get meta data activity, the dataset path should be only till that folder. So, you cannot use the above dataset for your Get meta data activity as it has dynamic file path.

Create another dataset with path till your source folder and give that to your Get meta data activity at first.

Similarly, do the same for the sink dataset as well. Here, the parameter name is target_filename.

enter image description here

Now, the dataset properties will get appear for both source and sink in copy activity. Give the file name @item().name to these parameters.

enter image description here

In your sink, you have given @item().name expression to copy behavior. Remove it and give the same to the dataset parameter.

enter image description here

Now, the source file(s) will get copied to the target location with same file name.

enter image description here

Upvotes: 2

Related Questions