You can use token replace task (if you pick this you need to define token in file and then define variables in you pipeline which will be used to replace those tokens. You can define variables gorups to hold variables per envrionment and switinch between variables for releases) but for your case I recommend to use parameters files per envrionment. In taht way you will be just changing file for environment on deployment.
Taken from docs:
To deploy to different environments, create more than one parameter
file. When naming the parameter file, add a way to identify its use.
For example, use azuredeploy.parameters-dev.json and
azuredeploy.parameters-prod.json
Then you can use AzureResourceGroupDeployment@2
to select proper parameter file (in case below it is WebSite.parameters.json
)
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy template'
inputs:
deploymentScope: 'Resource Group'
ConnectedServiceName: 'demo-deploy-sp'
subscriptionName: '01234567-89AB-CDEF-0123-4567890ABCDEF'
action: 'Create Or Update Resource Group'
resourceGroupName: 'demogroup'
location: 'Central US'
templateLocation: 'URL of the file'
csmFileLink: '$(artifactsLocation)WebSite.json$(artifactsLocationSasToken)'
csmParametersFileLink: '$(artifactsLocation)WebSite.parameters.json$(artifactsLocationSasToken)'
overrideParameters: '-_artifactsLocation $(artifactsLocation) -_artifactsLocationSasToken "$(artifactsLocationSasToken)"'
deploymentMode: 'Incremental'