I have a key vault and a app service hosted on Azure. I have a secret stored in that key vault that i want to consume its value directly in app service. I mean by directly that i be able to override the env. variable with the value of the secret directly withou any code interventions as it is showen in the screenshot.
I created a managed identity for the app service and give access role to it from the key vault and they are perfectly connected.
I tried to use this pattern @Microsoft.KeyVault(SecretUri=https://key-vault.vault.azure.net/secrets/encryption-key)
in order to try to get the value but did not succeed.
So I need a solution for it without also automating the flow using power automate. I need a solution on azure that enable me to read and get the value in the key vault and put it in the env.variables of the app service.
My Secrets
:
Key & Secret Management
, by selecting the Principal as the deployed app name.put it in the env.variables of the app service
You can manually add the key-value with key vault reference in the Environment Variables.
You need to reference the value with only the secret name( do not include the identifier id), it gets the latest value .
@Microsoft.KeyVault(SecretUri=https://HarshuKVJuly.vault.azure.net/secrets/SampleSecret)
Refer this MSDoc which explains the same.
Secret may have the multiple versions.
Pull reference values
..cshtml
page.@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
var SampleSecret = Environment.GetEnvironmentVariable("SampleSecret");
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>@SampleSecret</p></div>