title: How to use a variable group in a Azure Pipelines yml template?
body: <p>So I'm working on a bunch of pipelines and I've set everything up using yml templates. However I struggle with getting protected variable expanded inside of my template steps. I've tried passing in the protected variables by normal means, but they seem to not get expanded. Then I tried using a variable group, which I supposedly can directly reference inside of templates. I say supposedly, because Microsoft says so on their website <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&amp;tabs=yaml" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&amp;tabs=yaml</a>:</p>
  <p>&quot;You can also reference a variable group in a template. In the template variables.yml, the group my-variable-group is referenced. The variable group includes a variable named myhello.&quot;</p>
  <pre><code>variables:
  - group: my-variable-group
  </code></pre>
  <p>However, whenever I include a <code>variables</code> section into my template code, Azure DevOps immediately complains about it when parsing the yml, before running the pipeline. It spits out the following message:</p>
  <p>/ymls/my-template@my-repo (Line: 1, Col: 1): Unexpected value 'variables'</p>
  <p>I don't insist on using variable groups, I just want to have my protected variables expanded in my yml template. Does anybody know how to do that???</p>
  <p>Any help greatly appreciated!</p>