Home > Mobile >  Azure DataFactory Foreach Copy Upsert, howto use key column
Azure DataFactory Foreach Copy Upsert, howto use key column

Time:12-07

Im using azure data factory to copy a table from a mysql source to a sql server destination. Im using the default 'record' functionality. In the copy step, i want to enable upsert. I then need to enter the key columns, and im wondering how to make sure that each table can have its own key column(s).

See image here

And key column definition

Tried entering column names, however the end result looks confusing, what is the key then for which table?

CodePudding user response:

In order to give the key columns dynamically, in lookup table, a field called key_column is added for every table_name. Below is the detailed approach.

  • Lookup table is taken with fileds table name and key column. In ADF, lookup activity dataset is taken with the lookup table.

enter image description here

  • In for-each activity, lookup table output is taken.

enter image description here

  • Copy activity is taken in for-each activity. Source dataset is taken like below image.

enter image description here

  • In sink dataset, write behaviour is given as 'upsert' and key columns is given dynamically as @array(item().key_column

enter image description here

  • By this way key columns can be assigned dynamically and upsert can be performed in copy activity
  • Related