Unable to read value from Azure Key Vault

I applied the Azure Key Vault app in my Azure Functions app, following this article: https://medium.com/statuscode/getting-key-vault-secrets-in-azure-functions-37620fd20a0b

As described in the article, I use Managed Service Identity (MSI), but it looks like I cannot read values ​​from Key Vault. Below is the line that should read the value.

var myValue = (await kvClient.GetSecretAsync(Environment.GetEnvironmentVariable("documentDbkey"))).Value;

Here's what my entries in Azure KeyVault look like: enter image description here

Should I use keyie documentDbor the version identifier that starts with bf2550f4e?

Here's the error:

: IngridNotificationsFunction Microsoft.Azure.WebJobs.Host.FunctionInvocationException: : IngridNotificationsFunction --- > System.ArgumentNullException: . : secretIdentifier async Microsoft.Azure.KeyVault.KeyVaultClientExtensions.GetSecretAsync(??)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Ingrid.Notifications.IngridNotifications.Initialize() at C:\Users\Sam\Documents\Visual Studio 2017\Projects\Ingrid.Notifications\Ingrid.Notifications\IngridNotifications.cs: 83 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Ingrid.Notifications.IngridNotifications.Run(String myQueueItem) C:\Users\Sam\Documents\Visual Studio 2017\Projects\Ingrid.Notifications\Ingrid.Notifications\IngridNotifications.cs: 38 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker 2.InvokeAsync[TReflected,TReturnType](TReflected instance,Object[] arguments) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\VoidTaskMethodInvoker.cs : 20 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker 2.InvokeAsync [TReflected, TReturnValue] ( instance, Object []) C:\Projects\-webjobs--rqm4t\SRC\Microsoft.Azure.WebJobs.Host\\FunctionInvoker.cs: 63 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance) C:\\-webjobs--rqm4t\SRC\Microsoft.Azure.WebJobs.Hos...

, Azure KeyVault?

+4
1

System.ArgumentNullException: null


, , Environment.GetEnvironmentVariable("documentDbkey") null.

, Azure KeyVault?

Environment.GetEnvironmentVariable( "documentDbkey" ), azure, documentDb https://{yourkeyvalue}.vault.azure.net/Secrets/{yourSecretName} .

enter image description here

enter image description here

Update:

, .

kvClient.GetSecretAsync("https://{yourkeyvalue}.vault.azure.net/Secrets/{yourSecretName}")​.Value

enter image description here

, .

, ( ) , - ,

+2

Source: https://habr.com/ru/post/1691332/


All Articles