Approach 1)
You can add Environment variable in the ARM template and use it for different environments in your pipeline like below:-
"connectionstring": {
"type": "string"
},
"environment": {
"type": "string"
}
},
"variables": {
"storageBlobDataContributorRoleID": "ba92f5b4-2d11-453d-a403-e96b0029c9fe",
"defaultDataLakeStorageAccountUrl": "[concat('https://', parameters('defaultDataLakeStorageAccountName'), '.dfs.core.windows.net')]",
"connectionString": "[if(equals(parameters('environment'), 'Production'), parameters('connectionStringProd'), parameters('connectionStringNonProd'))]"
Output:-

The above parameter checks, If the environment variable is set to Production, then it uses Production connection string or else other environment.
Approach 2)
You can also mention each production in the Azure DevOps Pipeline variables yaml script and use it in the Azure Pipelines like below:-
trigger:
- main
variables:
- name: DevEnvironment
value: "env-url"
- name: TestEnvironment
value: "env-url"
- name: PreProdEnvironment
value: "env-url"
- name: ProdEnvironment
value: "env-url"
stages:
- stage: Build
displayName: 'Build stage'
jobs:
- job: Build
displayName: 'Build job'
steps:
- script: echo 'Building the Synapse Analytics workspace...'
displayName: 'Build step'
- stage: DeployToDev
displayName: 'Deploy to Development'
dependsOn: Build
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
jobs:
- job: Deploy
displayName: 'Deploy job'
steps:
- task: AzureResourceGroupDeployment@2
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'MyAzureResourceManagerConnection'
subscriptionId: '<subscription-id>'
action: 'Create Or Update Resource Group'
resourceGroupName: '<resource-group-name>'
location: '<resource-group-location>'
templateLocation: 'Linked artifact'
csmFile: '<path-to-arm-template>'
csmParametersFile: '<path-to-arm-template-parameters>'
overrideParameters: '-environment $(DevEnvironment)'
- stage: DeployToTest
displayName: 'Deploy to Test'
dependsOn: Build
condition: and(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'Schedule'))
jobs:
- job: Deploy
displayName: 'Deploy job'
steps:
- task: AzureResourceGroupDeployment@2
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'MyAzureResourceManagerConnection'
subscriptionId: '<subscription-id>'
action: 'Create Or Update Resource Group'
resourceGroupName: '<resource-group-name>'
location: '<resource-group-location>'
templateLocation: 'Linked artifact'
csmFile: '<path-to-arm-template>'
csmParametersFile: '<path-to-arm-template-parameters>'
overrideParameters: '-environment $(TestEnvironment)'
- stage: DeployToPreProd
displayName: 'Deploy to Pre-Production'
dependsOn: Build
condition: and(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'Manual'))
jobs:
- job: Deploy
displayName: 'Deploy job'
steps:
- task: AzureResourceGroupDeployment@2
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'MyAzureResourceManagerConnection'
subscriptionId: '<subscription-id>'
action: 'Create Or Update Resource Group'
resourceGroupName: '<resource-group-name>'
location: '<resource-group-location>'
templateLocation: 'Linked artifact'
csmFile: '<path-to-arm-template>'
csmParametersFile: '<path-to-arm-template-parameters>'
overrideParameters: '-environment $(PreProdEnvironment)'
- stage: DeployToProd
displayName: 'Deploy to Production'
dependsOn: Build
condition: and(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'Manual'))
jobs:
- job: Deploy
displayName: 'Deploy job'
Approach 3)
Alternatively you can also configure different stages Dev, Test, Prod, Pre-Prod to deploy your Synapse workspace in specific environment like below:-
