I know you can restore deleted secrets, however, I want to delete the current version and restore an older version.
5 Answers
I do not think this is possible. However, you can try PowerShell to get the old version of the secret using the cmdlet Get-AzureKeyVaultSecret
with -Version
parameter, store the returned secret in a variable, say $oldsecret
and then use the Set-AzureKeyVaultSecret
cmdlet to update the existing secret in Key Vault with the $oldsecret
.

- 898
- 1
- 5
- 9
there is no way to do this. All I can do is create a new secret, which I don't need. the value didn't change, just the tags. So I had to update our code to use the new version. at least the old version was still enabled so nothing broke during the changes.
One hack is to download the specific version that you want to be the current version and then set it in the KV using the az cli
.
az keyvault secret download --vault-name <vault-name> --name <secret-name> --version <secret-version> --file <output-file>
az keyvault secret set --vault-name <vault-name> --name <secret-name> --file <output-file>

- 31
- 1
No, It's not possible. An alternative is to take following steps using PowerShell:
Make sure Az module is installed on your local computer, if not run
Install-Module Az
Get your secret:
Get-AzKeyVaultSecret -VaultName 'vaultnumber' -Name 'secretname' -Version 'versionnumber' -AsPlainText | Out-File -FilePath .\Process.txt
edit your saved file, save and close it and read the file:
$text = Get-Content -Path 'path' -Raw
Write it to the key vault
$newSecret= ConvertTo-SecureString $text -AsPlainText -Force
Set-AzKeyVaultSecret -VaultName vaultnumber -Name secretname -SecretValue $newSecret

- 53
- 11