How do I retrieve the "secret value" in my Azure Function without using the properties of the Azure function?
Note: The value for the secret URL can be different every time the function is called, so it needs to resolve while running the application and not using configuration or function properties.
Similar problem but not solved using IBinder (my preferred solution):
- Can Azure Key Vault be used with Functions to store the connection string for queue triggers?
- How to map Azure Functions secrets from Key Vault automatically
[FunctionName("functionName")]
public async static void Run(
[QueueTrigger("queueName", Connection = "StorageConnectionAppSetting")],
IBinder binder,
ILogger log)
{
// TODO: how to resolve access from IBinder
binder.
}
background for the problem:
I have an application that has stored key/value pair within the Azure KeyVault in secrets while storing the data, I keep the Identifier for later retrieval:
"ClientSecretUri":"https://keyvault.vault.azure.net:443/secrets/1-ff6b03fc-12e8-427f-fa18-08d845672373/78c0211ceb5140a8990dec450eef1d23"
my code for storing the value is:
var kvc = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(
AzureAccessToken.GetAccessToken(APP_CLIENT_ID, APP_CLIENT_SECRET)
));
var secretBundle = await kvc.SetSecretAsync(KEYVAULT_BASE_URI, keyToStoreInValut, clientSecret);
var ClientSecretUri = secretBundle.SecretIdentifier.Identifier;