<p>My understanding of the variable groups is that you would create this to leverage the same variables across multiple pipelines.  If you needed to update the value, you'd only have to update it on the library instead of updating it on dozens of pipelines.  If you are only going to use the variable group on a single pipeline definition, variables groups appear to be overkill.</p>

<p>If you have concerns about duplicating code and maintaining the exact same deployment steps across your stages, I would recommend you group them into a task group.  That way you can manage versioned updates and will also have it reflected across all pipelines and stages where it is referenced.</p>

<p>I think you would have some name resolution issues if you tried to use the different variable groups that have the same name on a single pipeline.  Instead, you should probably leverage the variable scope on the pipeline.  It will grab the appropriate value staged to the scope you are executing.</p>

<p><a href="https://i.sstatic.net/OQeKk.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OQeKk.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-07-03T06:27:56.677Z
Thanks for your response. Since then I've discovered task groups and they look good. Now my only (minor) concern is that I have to recreate the same named variables across variable groups. Like if I have four logging servers across four environments, I have to create a variable in each variable group called `MyLoggingServer`. I guess I'm looking for some kind of variable template or something.
Nick.Mc
CC BY-SA 4.0
2019-12-08T15:17:29.010Z
@Nick.McDermaid - I'm going through the same process as discussed in this posting. I wonder, whether you are able to automate the deployment by having variables predefined which will be easier for the DevOps team to do the deployment.
goofyui
CC BY-SA 4.0
2019-12-08T23:26:53.507Z
Well.. DevOps is all about automating deployments. Variable Groups do predefine variables it's just that you have to manually copy for each environment
Nick.Mc
CC BY-SA 4.0
2019-07-02T18:12:58.067Z
2019-07-02T18:12:58.067Z
Matt
<p>I'm using DevOps to deploy Azure Data Factory ARM template</p>

<p>I'm using a deployment pipeline to take artifacts from a prior build pipeline and deploy to various environments (TEST, PROD)</p>

<p>I've created two variable groups: <code>TEST</code> and <code>PROD</code>. I've created two deployment "stages" <code>TEST</code> and <code>PROD</code></p>

<p>Within the <code>TEST</code> variable group I've created a bunch of variables reflecting the <code>TEST</code> specific configuration.</p>

<p>As far as I understand, I now have to manually recreate all of these identically named variables in my <code>PROD</code> variable group.</p>

<p>Not only that I have to make a copy of my TEST stage</p>

<p>So I basically have two duplicate configs and two duplicate stages</p>

<p>It would make more sense if I had a single stage definition that could be run against different variable groups rather than repeating code and variable group definitions.</p>

<p>It seems strange and redundant to have to do this. I also find it strange that the concept of environments is not specifically called out in doco anywhere</p>

<p>So the specific question is: Is it the correct approach to define a variable group per environment then manually create identical variables in both variable groups?</p>

<p>and a more general question: am I missing something fundamental here or is the product not mature enough yet.</p>

<p>I have not used any other deployment tool in any detail before this and I'm not using YAML (just the UI) so maybe that's the piece I'm missing.</p>

<p>Another "What Am I missing" thing:</p>

<p>In the <em>Resource Group deployment</em> task in the <em>override template parameters</em> field I used the UI to assign variables to parameter values. I had to type the variables in and had to make sure I got the magic notation right. <code>$(myVariable)</code> Then I read another stack overflow that indicated if your variable value has a space in it you need to surround it by quotes. This is the second "you need quotes for spaces" issue I have found.</p>

CC BY-SA 4.0
2019-06-20T00:07:52.087Z
LOL this question got a tumbleweed badge. Thanks guys! Is it echoing in here?
Nick.Mc
<azure-devops><azure-pipelines><environment-variables>
Can we reuse Variables across variable groups in Azure DevOps?
Nick.Mc
# Can we reuse Variables across variable groups in Azure DevOps?

(Asked by: username_0 on 2019-06-10)

I'm using DevOps to deploy Azure Data Factory ARM template

I'm using a deployment pipeline to take artifacts from a prior build pipeline and deploy to various environments (TEST, PROD)

I've created two variable groups: `TEST` and `PROD`. I've created two deployment "stages" `TEST` and `PROD`

Within the `TEST` variable group I've created a bunch of variables reflecting the `TEST` specific configuration.

As far as I understand, I now have to manually recreate all of these identically named variables in my `PROD` variable group.

Not only that I have to make a copy of my TEST stage

So I basically have two duplicate configs and two duplicate stages

It would make more sense if I had a single stage definition that could be run against different variable groups rather than repeating code and variable group definitions.

It seems strange and redundant to have to do this. I also find it strange that the concept of environments is not specifically called out in doco anywhere

So the specific question is: Is it the correct approach to define a variable group per environment then manually create identical variables in both variable groups?

and a more general question: am I missing something fundamental here or is the product not mature enough yet.

I have not used any other deployment tool in any detail before this and I'm not using YAML (just the UI) so maybe that's the piece I'm missing.

Another "What Am I missing" thing:

In the *Resource Group deployment* task in the *override template parameters* field I used the UI to assign variables to parameter values. I had to type the variables in and had to make sure I got the magic notation right. `$(myVariable)` Then I read another stack overflow that indicated if your variable value has a space in it you need to surround it by quotes. This is the second "you need quotes for spaces" issue I have found.

**Tags:** azure-devops, azure-pipelines, environment-variables

> **Comments:**
> **username_0**: LOL this question got a tumbleweed badge. Thanks guys! Is it echoing in here?  

---

## 1 answers

### Answer by username_1 on 2019-07-02. Score: 1 | Accepted answer

My understanding of the variable groups is that you would create this to leverage the same variables across multiple pipelines. If you needed to update the value, you'd only have to update it on the library instead of updating it on dozens of pipelines. If you are only going to use the variable group on a single pipeline definition, variables groups appear to be overkill.

If you have concerns about duplicating code and maintaining the exact same deployment steps across your stages, I would recommend you group them into a task group. That way you can manage versioned updates and will also have it reflected across all pipelines and stages where it is referenced.

I think you would have some name resolution issues if you tried to use the different variable groups that have the same name on a single pipeline. Instead, you should probably leverage the variable scope on the pipeline. It will grab the appropriate value staged to the scope you are executing.

[![enter image description here](https://i.sstatic.net/OQeKk.png)](https://i.sstatic.net/OQeKk.png)

> **Comments:**
> **username_0**: Thanks for your response. Since then I've discovered task groups and they look good. Now my only (minor) concern is that I have to recreate the same named variables across variable groups. Like if I have four logging servers across four environments, I have to create a variable in each variable group called `MyLoggingServer`. I guess I'm looking for some kind of variable template or something.  
> **username_2**: @username_0Dermaid - I'm going through the same process as discussed in this posting. I wonder, whether you are able to automate the deployment by having variables predefined which will be easier for the DevOps team to do the deployment.  
> **username_0**: Well.. DevOps is all about automating deployments. Variable Groups do predefine variables it's just that you have to manually copy for each environment  

---

