I'm having difficulties with variable expression with the AzureKeyVault task. Both the azureSubscription and KeyVaultName values expressions are not being resolved to have variables in a variable Group. It works if I define those variables manually in any way in the yaml. Either in azure-pipelines.yml or in the template variables_test.yml that I import at the beginning of the stage.
I read in the documentation, that variables from a variable group should be used like this $(var) but then it throws an error saying a subscription like '$(var)' does not exist.
Template: azure-pipelines.yml:
- stage: Test
variables:
- template: variables_Test.yml # Template reference
- group: testVariableGroup
dependsOn: []
jobs:
- job: Test
steps:
- task: AzureKeyVault@1
inputs:
azureSubscription: ${{ variables.spn_kv_app }}
KeyVaultName: ${{ variables.keyVaultName }}
SecretsFilter: '*'
In the logs from the staging i can see the variables being set from the variable group:
Job preparation parameters
Variables:
keyVaultName: $[ variablegroups.testVariableGroup.keyVaultName ]
resourceGroupName: $[ variablegroups.testVariableGroup.resourceGroupName ]
spn_cd_app: $[ variablegroups.testVariableGroup.spn_cd_app ]
spn_kv_app: $[ variablegroups.testVariableGroup.spn_kv_app ]
storageAccountName: $[ variablegroups.testVariableGroup.storageAccountName ]
Important thing to note that those variables are not set to secrets in the variable group.
PS. For anyone interested. I created tickets:
https://github.com/MicrosoftDocs/vsts-docs/issues/7586
If anything will be reslved i will post an answer.


azureSubscriptionand a few other values in tasks other than Key Vault - Gregg LazureSubscriptionfield in the Azure CLI task, but I haven't tried Azure Powershell yet - Gregg L