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:
- 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"
}
}
- 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')]"
}
}
}
]
}
- 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:
- https://learn.microsoft.com/en-us/answers/questions/186623/parametrizing-adf-event-triggers-storage-account-f
- https://learn.microsoft.com/en-us/answers/questions/2085254/how-to-set-adf-linked-services-and-triggers-parame
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.