Thursday, September 12, 2024

Don't Forget To Update That Azure Key Vault URL When Creating A New Version...Wait...Just Get The Latest


 
Sometimes you need to update a Secret in an Azure Key Vault and you may be referencing that from an Environment Variable. 

If you use ADF when you reference a Key Vault in a Linked Service it goes to the latest version automatically. 

When adding it as an environment variable so a Function could access it (securely and the MS way), I've used:

@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret/ec96f02080254f109c51a1f14cdb1931)

If the value was changed, I would often forget to update the version reference.

After some errors I've moved it to just be:

@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret/)
 
In this way it does not need to reference the version so it will always get the latest value and there's nothing to remember for the specific reference. Just change it in Key Vault and that's it!