How to Set Sink FileName to Variable Value

Lilly W 130 Reputation points

I have a dynamic variable. How do I set the file name in the sink to the variable?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,064 questions
0 comments No comments
{count} vote

Accepted answer
  1. Suba Balaji 10,931 Reputation points

    Lilly W

    Thanks for the ask and using MS Q&A platform.

    Here is a video that explains the steps for both copy and data flow activities. Below steps are for copy activity.

    If you are using a copy activity, and want to pass variable value as file name in sink, please follow below steps.

    • create a parameter called filename in sink dataset as shown below and use the parameter in the filename part of the data set Screenshot 2023-07-19 at 10.28.08 AM
    • Next, use the parameter created above in the connection tab of the dataset, in the filename portion as shown below Screenshot 2023-07-19 at 10.27.48 AM
    • Go to copy activity and click on sink
    • Now you will be able to see the filename parameter in the sink
    • click on the dynamic expression and choose the variable name which contains the file name and you are done. Screenshot 2023-07-19 at 10.33.27 AM
    • Im having the below expression in my set variable expression

    what i am trying to do is, to capture current date in MMddyyyy format dynamically and suffix it next to my filename and then finally using .csv. (Basically i am trying to convert a ,xlsx file to .csv file with current date in the file name)

    After i ran the pipeline, i see my file getting converted to .csv as well as using the dynamic name I am deriving in my set variable activity. Hope this helps.

    Screenshot 2023-07-19 at 10.49.04 AM

1 additional answer

Sort by: Most helpful
  1. Sedat SALMAN 12,200 Reputation points

    Add parameter (sinkFilename)

    Add Copy Data activity

    Select source dataset

    Select sink data source

    Pass the parameter to the sink dataset

    Add dynamic content to the File Path

    Use the following expression

    0 comments No comments