I have Azure DevOps pipeline variable group, which cannot list Key Vault. However pipeline can set secrets. What could be wrong?
NOT FINDING KEY VAULT AT ALL:
- Create Variable Group in Library of Azure DevOps
- Select Service Principal as Subscription
- No Key vault instance is listed in drop down
KEY VAULT ACCESS POLICY
- Application: Service Principal
- Key Permission: List
- Secret Permission: Get, List, Set
WORKING CODE IN PIPELINE:
$ConnectionString = az storage account show-connection-string -g $(resource-group) -n sa$(project-
name)$(environment) -o "tsv"
$CurrentConnectionString = az keyvault secret show --name StorageAccountConnectionString --vault-name
$(key-vault-name) --query value -o "tsv"
if (!($ConnectionString -eq $CurrentConnectionString)) {
az keyvault secret set -n StorageAccountConnectionString --vault-name $(key-vault-name) --value $ConnectionString -o none
}
else {
write-host("Secret already in key vault!")
}
service connection
connection method(auto / manual) – Kevin Lu-MSFT