Parameterizing Linked Services and Datasets in Azure Data Factory V2 using code (JSON)

As of today, ADF V2 does not support parameterizing of Linked Services from UI for various connectors. Only a few connectors are supported. You can still parameterize any linked service using code(JSON). 

Here's how you can do it (I am using a REST connection for example, it can be extended to any Linked Service):

  • Create a Linked Service with some static values and save it.
  • In the Linked Services tab, click on the code icon (highlighted) of the Linked Service you just created :
    https://social.msdn.microsoft.com/Forums/getfile/1488249
  • Within properties, add an attribute "parameters" in the following form  :
{
 
"name":
 
"RestServiceWithParameters",
 
"type":
 
"Microsoft.DataFactory/factories/linkedservices",
 
"properties": {
 
"type":
 
"RestService",
 
"annotations": [],
 
"typeProperties": {
 
"url":
 
"https://reqres.in/api/users?page=@linkedService.pageNo",
 
"enableServerCertificateValidation":
 
false,
 
"authenticationType":
 
"Anonymous"
 
},
 
"parameters": {
 
"pageNo": {
 
"type":
 
"String"
 
}
 
}
 
}
 
}
  • You can also reference this parameter (pageNo) now as @linkedService.pageNo
  • as shown in the above example.
  • Create a dataset using this connection. You would be asked to pass a value for the Linked Service (pageNo). You can parameterize the dataset too. To do so, you can pass a value to the parameter as shown below :
    https://social.msdn.microsoft.com/Forums/getfile/1488255
  • You can add this parameter to the dataset (pageNum) by clicking on the add dynamic content while assigning value to the Linked Service parameter (pageNo). You will see a '+' icon to add a dataset parameter as shown below :
    https://social.msdn.microsoft.com/Forums/getfile/1488258
  • Voila, you are done. In your copy activity or any activity, you would now have to just pass a value to the dataset parameter (pageNum) which would pass that value to the Linked Service (pageNo) as shown below :
  • https://social.msdn.microsoft.com/Forums/getfile/1488259

Hope this helps.