How to parameterize the scope property or the subscription name in the event trigger in ADF between different environment

Ganapathy, Muthu Mari (Cognizant) 0 Reputation points
2025-02-13T10:03:23.7466667+00:00

How to parameterize the scope property or the subscription name in the event trigger in ADF between different environments. I want to dynamically use the subscription name between the different environments.

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

1 answer

Sort by: Most helpful
  1. Sina Salam 18,876 Reputation points
    2025-02-13T17:08:17.0866667+00:00

    Hello Ganapathy, Muthu Mari (Cognizant),

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to parameterize the scope property or the subscription name in the event trigger in Azure Data Factory (ADF) to dynamically use the subscription name between different environments.

    The below steps are a detailed step-by-step guide:

    1. Define parameter files for each environment (e.g., dev-parameters.json, test-parameters.json, prod-parameters.json). For an example dev-parameters.json:
         {
           "subscriptionName": {
             "value": "dev-subscription-id"
           }
         }
    
    1. In your ARM template, define parameters for the scope property or subscription name similar to the below snippet:
       {
         "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
         "contentVersion": "1.0.0.0",
         "parameters": {
           "subscriptionName": {
             "type": "string"
           }
         },
         "resources": [
           {
             "type": "Microsoft.DataFactory/factories/triggers",
             "apiVersion": "2018-06-01",
             "name": "[concat(parameters('factoryName'), '/triggerName')]",
             "properties": {
               "type": "BlobTrigger",
               "typeProperties": {
                 "scope": "[concat('/subscriptions/', parameters('subscriptionName'), '/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageAccountName')]"
               }
             }
           }
         ]
       }
    
    1. When deploying your ADF resources, use your CI/CD pipeline (e.g., Azure DevOps, GitHub Actions) to inject the appropriate parameter file based on the target environment. For an example of Azure DevOps pipeline YAML:
       parameters:
         - name: environment
           displayName: Select Environment
           type: string
           default: dev
           values:
             - dev
             - test
             - prod
       jobs:
         - job: DeployADF
           steps:
             - task: AzureResourceManagerTemplateDeployment@3
               inputs:
                 deploymentScope: 'Resource Group'
                 azureResourceManagerConnection: 'AzureRMConnection'
                 subscriptionId: '$(subscriptionId)'
                 action: 'Create Or Update Resource Group'
                 resourceGroupName: '$(resourceGroupName)'
                 location: '$(location)'
                 templateLocation: 'Linked artifact'
                 csmFile: '$(System.DefaultWorkingDirectory)/templates/azuredeploy.json'
                 csmParametersFile: '$(System.DefaultWorkingDirectory)/parameters/$(environment)-parameters.json'
    

    For more reading and steps, you can use the following links:

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


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.