Avoid creating new azure key vault secret version if one already exists in C#

59 Views Asked by At

I am writing my own Azure KeyVault wrapper in C#, and I would like to have a functionality that allows me to specify what should happen if I attempt to upload a secret using a name that already exists:

public enum ActionIfExists
{
  Fail,
  Rename,
  Overwrite
}

But when I was trying to implement this, I couldn't see how one would actually check if a secret exists using the methods of the SecretClient. Neither have I found a setting in the SecretClientOptions or method parameters for SetSecretAsync to tell it to "fail upon collisions", or something that would prevent silent overwrites.

I have now implemented this "exists" by downloading the secret, and returning true if it succeeds or false when an error occurs. But I'd rather have a function like BlobContainerClient.ExistsAsync than needlessly downloading sensitive data "as a test".

Has anyone ever done this or an idea why it isn't possible?

0

There are 0 best solutions below