Home > database >  Azure Dev ops variable scope
Azure Dev ops variable scope

Time:12-16

When deploying release using Azure Dev Ops, the variable value is preserved between two stages instead of being overwritten as expected.

I am using azure dev ops to deploy data factory with its resources to different environments

  • Test Environment
  • UAT Environment

I have 2 variable groups defined in "Library" respectively for each stage of deployment

  • Test-config and
  • Uat-config

Both of those have a variable by name varDataFactory - to keep the data factory name When linking the variable group in the pipeline "Variables" tab, I specify the stage at which i am expecting it to execute against. enter image description here

So, the variable varDataFactory is expected to have different value at each stage. Basically the first stage executes, creating the Test Data Factory, but then when UAT stage deploys, it "sees" the "varDataFactory" with its old value - the one for the "test".

And I do not know why, and what to do about it. Especially, since I have another pair of variable groups for Key vaults (2 different vaults for 2 environments) and those get in just file. Please, help !!

CodePudding user response:

As you have 2 different configuration groups for 2 different stages, then I don't understand what do you mean by overwriting.

I tried this with a simple command line task in release pipeline with below configurations:

  • Variable Group: test-config, Variable name: varDF, value: testdatafactory
  • Variable Group: uat-config, Variable name: varDF, value: uatdatafactory

Pipeline variable Configuration: enter image description here

Below are the outputs for echo$(varDF) command in test and UAT stages: enter image description here

enter image description here

  • Related