I'm facing an issue with my Azure DevOps pipeline where I can successfully retrieve one secret from Azure Key Vault, but not the others. Specifically, I'm able to retrieve one secret, but when I try to retrieve other secrets, they are not being set correctly in the pipeline.
Azure Key Vault Configuration:
my-keyvault
).SecretOne
SecretTwo
SecretThree
SecretFour
Access Policies:
Get
and List
permissions for secrets.Azure DevOps Pipeline Configuration:
AzureKeyVault@1
task.Here is the simplified version of my pipeline script for testing secret retrieval:
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureKeyVault@1
inputs:
azureSubscription: 'my-azure-subscription'
KeyVaultName: 'my-keyvault'
SecretsFilter: 'SecretOne,SecretTwo,SecretThree,SecretFour'
RunAsPreJob: true
- script: |
echo "SecretOne: ${SecretOne}"
echo "SecretTwo: ${SecretTwo}"
echo "SecretThree: ${SecretThree}"
echo "SecretFour: ${SecretFour}"
displayName: 'Print Secrets for Verification'
SecretOne
is correctly retrieved and printed.SecretTwo
, SecretThree
, and SecretFour
) are not being retrieved and printed.Verified Access Policies:
Get
and List
permissions in the Key Vault.Checked Secret Names:
Tested with Azure CLI:
I need assistance in understanding why only one secret is being retrieved successfully while the others are not. Any insights or suggestions on what might be going wrong and how to fix this issue would be greatly appreciated.
Thank you in advance for your help!
Azure Pipelines makes an effort to mask secrets when emitting data to pipeline logs, so you may see additional variables and data masked in output and logs that are not set as secrets.
This is by design, as you don't want sensitive information being exposed in the logs.
Example:
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureKeyVault@1
inputs:
azureSubscription: 'repo-kv-demo'
KeyVaultName: 'kv-demo-repo'
SecretsFilter: 'secretDemo'
RunAsPreJob: true
# other tasks here
- bash: |
echo "Secret Found! $MY_MAPPED_ENV_VAR"
env:
MY_MAPPED_ENV_VAR: $(secretDemo)
The output from the bash command should look like this:
Secret Found! ***