没有代码的Azure App设置中的关键保管库设置 [英] Key Vault Settings in Azure App Settings with no code

查看:48
本文介绍了没有代码的Azure App设置中的关键保管库设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用HTTPTrigger创建了一个简单的Azure函数,该函数通过Azure中的门户返回密钥集的秘密值.该值存储为

I created a simple Azure function with a HTTPTrigger that returns the secret value for a key set through the portal in Azure. The value is stored as

@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret/ec96f02080254f109c51a1f14cdb1931)

该功能在平台功能">身份"中启用了系统分配的托管身份. Key Vault的机密已添加值.密钥保管库还定义了访问策略,该访问策略具有对应用程序主体的密钥,机密和证书的完全访问权限.功能应用程序仍按原样返回值,而不是秘密值,这可能是Key Vault访问问题的迹象.正确检索值缺少什么?

The Function has system assigned managed identity enabled in Platform Features>Identity. The Key Vault has the secret added with the value. The Key Vault also has an Access Policy defined with full access for keys, secrets and certificates for the Application principal. The function app still returns the value as-is and not the secret value which may be a sign of access issues with Key Vault. What is missing to retrieve the values correctly?

https://medium.com/statuscode/getting-key-vault-secrets-in-azure-functions-37620fd20a0b

public static class FunctionCoreAnonymous
{
    static string superSecret = Environment.GetEnvironmentVariable("SuperSecret");
    [FunctionName("FunctionCoreAnonymous")]
    public static async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
    {
        return (ActionResult)new OkObjectResult($"Hello, {superSecret}");
    }
}

推荐答案

跟随链接,它在我的网站中成功运行.根据这是一个新功能,它可能不稳定.

Followed the link and it works successfully in my site. According to this is a new feature, it may be not stable.

顺便说一句,我第一次像您一样按原样获得价值.但是,请稍等片刻,效果很好.因此,我认为读取密钥库机密可能会有所延迟.

BTW, in the first time I get the value as-is like you. But wait a little time, it works well. So I think it may have some delay to read the key vault secret.

这篇关于没有代码的Azure App设置中的关键保管库设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆