Hi ,
Thanks for reaching out to Microsoft Q&A.
- Use Global Parameters and Trigger Overrides
Global parameters are available across all pipelines and can be used to define environment-specific configurations. You can override the values dynamically based on the trigger used to run the pipeline.
Steps:
- Create Global Parameters:
- In ADF, go to "Manage" > "Global Parameters."
- Define a global parameter for the env, example:
Environment
.
- Override Global Parameter Values in Triggers:
- Create separate triggers for each environment (example:
Trigger_Dev
,Trigger_UAT
,Trigger_Prod
). - Override the global parameter
Environment
in each trigger with the branch/environment name.
- Create separate triggers for each environment (example:
- Use the Global Parameter in Pipelines:
- In your pipeline, reference the global parameter using
@pipeline().globalParameters.Environment
.
- In your pipeline, reference the global parameter using
- Dynamic Behavior:
- Pass the global parameter's value to your azfunc or any downstream linked service dynamically based on the trigger.
- Extract the Branch Name Dynamically
Unfortunately, ADF does not natively support detecting the Git branch during runtime. However, you can:
- Set an environment-specific variable in the trigger metadata or pipeline parameter, and pass it dynamically during pipeline execution.
Steps:
Parameterize Pipeline:
- Add a pipeline parameter named
BranchName
.
Set Parameter Value in Triggers:
- In each branch's trigger, pass the respective branch name as the parameter value (e.g., `dev`, `uat`, `prod`).
- Use the Parameter in Pipelines:
- Use
@pipeline().parameters.BranchName
wherever needed in activities or linked services.
- Use
3.Externalize Configuration in a Blob or Key Vault
Store the environment-specific configurations in a central location (ex: Azure Blob Storage or Key Vault) and dynamically fetch the configurations based on the branch.
- Dynamically Access Linked Service JSON Content
ADF does not support direct runtime access to the linked service JSON file. However, you can parameterize your linked services and dynamically pass environment-specific values.
- Use GitIgnored Files for Environment-Specific Parameters
You can maintain a settings.json
file in your repository for each branch and include it in .gitignore
to avoid conflicts during merges. Each branch can have its unique settings.json
file with environment-specific configurations.
Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.