question

Radhakrishnan-9977 avatar image
0 Votes"
Radhakrishnan-9977 asked ·

KeyVaultClient.GetSecretAsync(url) causing delay

We are using Azure KeyVault to store certain back end credentials that our Azure API uses to query. The GetSecretAsync call always takes at least 15 seconds to return. Is there any way to speed up this call. Below is the code used.


 KeyVaultClient kvClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(TokenBasedAccessHelper.GetToken));    
 var secret = Task.Run(async () => await kvClient.GetSecretAsync(url)).Result;
 return secret.Value
azure-webappsazure-key-vault
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Just curious but why are you using Task.Run and .Result instead of awaiting directly GetSecretAsync ? It seems weird.

0 Votes 0 · ·

Thanks for asking question! There is a common deadlock issue as the call never returns and the query hangs indefinitely. Also, If you’re in a non-async method, its let you use .Result

You may refer to blog Don't Block on Async Code might be helpful.

Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you.


0 Votes 0 · ·

0 Answers