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.
My Setup
Azure Key Vault Configuration:
- I have multiple secrets stored in Azure Key Vault (
my-keyvault). - The secrets include:
SecretOneSecretTwoSecretThreeSecretFour
- I have multiple secrets stored in Azure Key Vault (
Access Policies:
- The service principal used by Azure DevOps has
GetandListpermissions for secrets.
- The service principal used by Azure DevOps has
Azure DevOps Pipeline Configuration:
- The pipeline is configured to retrieve secrets using the
AzureKeyVault@1task. - I verified that the service principal has the correct access permissions.
- The pipeline is configured to retrieve secrets using the
Pipeline Script
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'
Issue
- The secret
SecretOneis correctly retrieved and printed. - The other secrets (
SecretTwo,SecretThree, andSecretFour) are not being retrieved and printed.
Debugging Steps Taken
Verified Access Policies:
- Confirmed that the service principal has
GetandListpermissions in the Key Vault.
- Confirmed that the service principal has
Checked Secret Names:
- Ensured that the secret names are correctly specified and match exactly, including case sensitivity.
Tested with Azure CLI:
- Verified that all secrets can be retrieved using Azure CLI commands.
Request for Help
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!
AzureKeyVault@2instead ofAzureKeyVault@1$(SecretXXX)instead of curly brackets${SecretXXX}?