Azure DataFactory .NET SDK CopyTranslator

Lou Driehuis 56 Reputation points
2021-09-30T14:52:42.387+00:00

Hi Guys,

I want to make a pipeline in Azure Data Factory with the use of the .NET SDK. I followed the given example and the basics work really fine and nice.
but I am really struggling with the Mapping of fields. I 'Binged' and 'Googled' the night away, but I found it really hard to find any examples of how to use the CopyTranslator or TabularTranslator.

For example when working with The CopyTranslator, I the properties 'Translator' or the CopyActivity to a a new Instance of CopyTranslator. Then I try to set the AdditionalProperties (IDictionary<String, Object>), but what needs to go into the value part of that dictionary???

Can somebody help me with this, or do you know some locations were I can find examples?
Help is very much appriciated.

Many thanks,
Lou

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

Accepted answer
  1. Saurabh Sharma 23,671 Reputation points Microsoft Employee
    2021-10-01T21:38:08.12+00:00

    Hi @Lou Driehuis ,
    Thanks for using Microsoft Q&A !!
    Please find below the .NET Code for your reference which you could use to add a Tabular Translator to a Copy Data activity.

    PipelineResource newSQLPipeline = new PipelineResource  
                {  
                    Parameters = new Dictionary<string, ParameterSpecification>  
                    {  
                        { "inputPath", new ParameterSpecification { Type = ParameterType.String } },  
                        { "outputPath", new ParameterSpecification { Type = ParameterType.String } }  
                    },  
                    Activities = new List<Activity>  
                    {  
                        new CopyActivity  
                        {  
                            Name = "CopyData",  
                            Inputs = new List<DatasetReference>  
                            {  
                                new DatasetReference()  
                                {  
                                    ReferenceName = sqlSourceDatasetName  
                                      
                                }  
                            },  
                            Outputs = new List<DatasetReference>  
                            {  
                                new DatasetReference  
                                {  
                                    ReferenceName = sqlSinkDatasetName                                  
                                }  
                            },  
                            Source = new SqlSource { },  
                            Sink = new SqlSink { },  
                            Translator =  new TabularTranslator()  
                            {  
                                Mappings = new List<Dictionary<string,Dictionary<string,string>>>()  
                                {  
                                    new Dictionary<string, Dictionary<string,string>>()  
                                    {  
                                        { "source",new Dictionary<string, string>(){{"name","Id" }}},  
                                        { "sink",new Dictionary<string, string>(){{"name","CustomerId" }}}  
                                    },  
                                    new Dictionary<string, Dictionary<string,string>>()  
                                    {  
                                        { "source",new Dictionary<string, string>(){{"name","Name" }}},  
                                        { "sink",new Dictionary<string, string>(){{"name","LastName" }}}  
                                    },  
                                    new Dictionary<string, Dictionary<string,string>>()  
                                    {  
                                        { "source",new Dictionary<string, string>(){{"name", "LastModifiedDate" } }},  
                                        { "sink",new Dictionary<string, string>(){{"name", "ModifiedDate" } }}  
                                    }  
                                },  
      
                            }  
                        }  
                    }  
                };  
    

    Results:
    137113-image.png

    Data Factory Mapping section -
    137059-image.png

    Please let me know if you have any questions.

    Thanks
    Saurabh

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.


1 additional answer

Sort by: Most helpful
  1. Lou Driehuis 56 Reputation points
    2021-10-05T15:10:17.16+00:00

    Hi @Saurabh Sharma ,

    Many thanks for you answer. It will certainly help.

    Ciao
    Lou

    0 comments No comments