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:
- 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.
- 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')]" } } } ]
- Open the exported ARM template and locate the
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>