How to set ADF linked services and triggers parameterized for respective environment when we create pull request (note: we are not planning to use azure Devops release pipeline for this we are planning to go with pull request process)

Madhu Ram 20 Reputation points
2024-10-03T07:58:02.7933333+00:00

How to set ADF linked services and triggers parameterized for respective environment when we create pull request (note: we are not planning to use azure Devops release pipeline for this we are planning to go with pull request process)

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,819 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 26,101 Reputation points
    2024-10-03T19:30:34.9033333+00:00

    To set up parameterized linked services and triggers for different environments (like development, testing, and production) when creating a pull request without using Azure DevOps release pipelines, you can follow these steps:

    1. Use ARM Templates

    Azure Data Factory allows you to export your factory as an ARM template. You can parameterize linked services and triggers in the ARM template.

    Steps to Export and Modify ARM Template:

    1. Export ADF as ARM Template:
      • Go to your Data Factory in the Azure portal.
      • Click on Author & Monitor.
      • In the ADF UI, go to the Manage tab (wrench icon).
      • Select ARM template from the left menu and click Export template.
    2. Modify the ARM Template:
      • Open the exported ARM template and locate the parameters section.
      • Add parameters for the connection strings, keys, or any other values that will differ between environments. For example:
        
             "parameters": {
        
               "databaseConnectionString": {
        
                 "type": "string",
        
                 "defaultValue": "DefaultConnectionString"
        
               },
        
               "triggerStartTime": {
        
                 "type": "string",
        
                 "defaultValue": "2024-01-01T00:00:00Z"
        
               }
        
             }
        
        
      • In the resources section, update the linked services and triggers to reference the parameters:
        
             "resources": [
        
               {
        
                 "type": "Microsoft.DataFactory/factories/linkedServices",
        
                 "name": "[concat(parameters('dataFactoryName'), '/MyLinkedService')]",
        
                 "properties": {
        
                   "type": "AzureSqlDatabase",
        
                   "typeProperties": {
        
                     "connectionString": "[parameters('databaseConnectionString')]"
        
                   }
        
                 }
        
               }
        
             ]
        
        

    2. Create Parameterized Triggers

    You can create triggers in the ARM template that reference parameters. This is similar to linked services.

    3. Use Parameter Files

    You can create parameter files for each environment. Each file will contain the specific values for that environment. For example:

    • dev.parameters.json:
      
        {
      
          "$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      
          "contentVersion": "1.0.0.0",
      
          "parameters": {
      
            "databaseConnectionString": {
      
              "value": "DevConnectionString"
      
            },
      
            "triggerStartTime": {
      
              "value": "2024-01-01T00:00:00Z"
      
            }
      
          }
      
        }
      
      
    • prod.parameters.json:
      
        {
      
          "$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      
          "contentVersion": "1.0.0.0",
      
          "parameters": {
      
            "databaseConnectionString": {
      
              "value": "ProdConnectionString"
      
            },
      
            "triggerStartTime": {
      
              "value": "2024-01-01T00:00:00Z"
      
            }
      
          }
      
        }
      
      

    4. Deploy Using Pull Requests

    When you create a pull request:

    • Ensure that the correct parameter file is referenced in your deployment command or script. For example, if using Azure CLI or PowerShell, you can specify the parameter file during deployment:
        
        az deployment group create --resource-group <your-resource-group> --template-file <path-to-template> --parameters <path-to-parameters>
        
      

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.