【问题标题】:Using managed identities in queue triggers in azure functions在 azure 函数的队列触发器中使用托管标识
【发布时间】:2019-05-10 13:38:20
【问题描述】:

我想使用托管身份而不是在存储帐户连接中配置的用户名和密码。我只看到使用连接字符串配置队列触发器的选项,但无法添加托管标识以避免配置机密。 这可能吗?

【问题讨论】:

    标签: azure azure-functions managed


    【解决方案1】:

    我很确定目前还不可能,您只能在函数运行时使用托管标识来访问资源,而不是触发器。我现在无法找到证据,在一些 GH 问题上看到过。

    【讨论】:

    • 是的,这也是我的猜测。如果连接字符串允许定义“UseManagedIdentity=True”之类的,这是可能的。
    • 是的,类似于 appservice 对 keyvault 参考所做的操作
    【解决方案2】:

    现在可以使用 Microsoft Azure 函数扩展库,例如“Microsoft.Azure.WebJobs.Extensions.Storage.Blobs”。

    托管身份的连接配置示例:

    "QueueSettings:StorageAccount": "",
    "QueueSettings:StorageAccount__queueServiceUri": "https://mytestfa.queue.core.windows.net/",
    "QueueSettings:StorageAccount__credential": "managedidentity"
    

    并像这样在函数触发器中引用连接:

     [Function("ProcessUserData")]
     public async Task ProcessUserData([QueueTrigger("%QueueSettings:UserDataQueue%", Connection = "QueueSettings:StorageAccount")] string queueItem, FunctionContext context)
     {
          var logger = context.GetLogger<QueueListener>();
          ... 
     }
    

    此处来自 Microsoft DevBlog 的原始公告: https://devblogs.microsoft.com/azure-sdk/introducing-the-new-azure-function-extension-libraries-beta/

    这里也可以参考: Azure Functions - use queue trigger with managed identity

    【讨论】:

      猜你喜欢
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-02
      • 2021-03-01
      • 1970-01-01
      • 2021-10-30
      相关资源
      最近更新 更多