Azure DevOps is great for automating your releases to Azure. On your Azure pipeline, you have an instant overview of the deployment: what source code is being deployed and to which environments? Unfortunately, you don’t have that visibility in Azure. When you discover some bugs in Azure, you easily want to understand when the last deployment occurred and what source code was deployed. This can be done with a little trick!
In your Bicep file, add an optional parameter and assign it as a tag on your resource group.
param devOpsUrl string = ''
//Create Resource Group resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: 'tvh-dev-temporary-rg' location: location tags: { environment: 'dev' devOpsUrl: devOpsUrl } }
- task: AzureCLI@2 displayName: 'Deploy infra' inputs: azureSubscription: '${{ parameters.serviceConnection }}' scriptType: 'pscore' scriptLocation: 'inlineScript' inlineScript: | az deployment sub create ` --location westeurope ` --template-file infra.bicep ` --parameters infra.parameters.${{ parameters.environment }}.json ` --parameters "devOpsUrl=$($env:SYSTEM_COLLECTIONURI)$($env:SYSTEM_TEAMPROJECT)/_build/results?buildId=$($env:BUILD_BUILDID)&view=results" workingDirectory: '$(Pipeline.Workspace)/infra'
Toon