I am attempting to put some output from a service I am running in a Key Vault in Azure. The output of my service will be user credentials which is why I want to use Key Vault for this purpose.
So far, I have tried the KeyVaultClient's SetSecretAsync method, but it's not working for me, I am not getting any error messages however I'm also not seeing a new secret created in my targetted KeyVault. I have not been able to find a KeyVaultClient Add Secret method as it does not exist, am I using the right object/method here?
The method in question here is AddResult.
Here is my code:
private static AzureKeyVault instance; private static KeyVaultClient client; private AzureKeyVault() { //initialize the azure key vault var vaultAddress = ConfigurationManager.AppSettings["VaultUri"]; client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetAccessToken)); } public static async Task<string> GetAccessToken(string authority, string resource, string scope) { var clientId = ConfigurationManager.AppSettings["ClientID"]; var clientSecret = ConfigurationManager.AppSettings["ClientSecret"]; ClientCredential clientCredential = new ClientCredential(clientId, clientSecret); var context = new AuthenticationContext(authority, TokenCache.DefaultShared); var result = await context.AcquireTokenAsync(resource, clientCredential); return result.AccessToken; } public static AzureKeyVault GetInstance { get { if (instance == null) { instance = new AzureKeyVault(); } return instance; } } public void AddResult(string machineIPAndPort, BruteForceResult result) { client.SetSecretAsync("https://vaultURI(redacted).vault.azure.net/", machineIPAndPort, JsonConvert.SerializeObject(result)); } 
SetSecretAsynccall (or.Resultif you're in a real hurry)? Works just fine for me.