Azure Devops - Issue while Extracting the Secret Value of the Key-Vault

Hitesh N 20 Reputation points
2025-05-29T03:16:39.51+00:00

I am getting the below Issue the Secret of the Key-Vault is coming as *** but after Base64 encoding it shows correct encoded-value.

But in Azure Devops PowerShell was facing issue while decoding the Encoded Base64 Key-Vault value.

  1. Then in PowerShell Script, to extract the Key-Vault values with the below command

$keyVaultValue = (Get-AzKeyVaultSecret -VaultName "xxx" -Name "DBPass")

Write-Host "Value of Value": $keyVaultValue

---- Output

Value of keyVaultValue : ***

After Encoding in Base64 for the above value of (keyVaultValue) getting the correct encoded-value. Checked in the base64 decode website (https://www.base64decode.org/) by encoded-value to check the decoded-value. ( Decoded-value is correct)

Encoded-Value

$encodedSecret = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($keyVaultValue))

Write-Host "Value of encodedSecret" $encodedSecret

---Output - for-example

Value of encodedSecret - xyz

Decoded-value

$decodedvalue = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('xyz'))

Write-Host "Value of DecodedSecret" $decodedvalue

---- Output

Value of decodedvalue : ***

Azure DevOps
0 comments No comments

6 answers

Sort by: Most helpful
  1. Hitesh N 20 Reputation points
    2025-06-04T13:13:13.61+00:00

    Thanks Durga tried above and also one different method it worked. Thanks for your help.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.