azure - 如何使用 Key Vault key 作为连接字符串来绑定(bind) Azure Functions 中的事件中心?

标签 azure azure-functions azure-keyvault azure-eventhub

我为 EventHubTrigger 开发了一个 Azure Function 应用。这是基本代码:

public static class MyEventHubTriggerFunction
{

    [FunctionName("MyEventHubTriggerFunction")]
    public static async Task Run([EventHubTrigger("EventHubName",
        Connection = "EventHubConnectionString")] 
        string[] eventHubMessages, 
        TraceWriter log, 
        ExecutionContext context)
        { ... }
}

这是我的 local.settings.json 文件:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "EventHubName": "<myEventHubName>",
    "EventHubConnectionString": "<myEventHubConnectionString>"
  }
}

部署此应用程序时,它可以在计算机或 Azure 上正常运行。这里必须将EventHubConnectionString粘贴到json文件中。

是否有任何方法可以使用 MSI 身份验证从 KeyVault key 中获取该值,并且应该自动在运行方法参数中实例化 EventHubTrigger 实例时使用该值?

我知道如何使用KeyVaultClient在函数范围内获取 secret ,但这里函数触发器run方法本身需要连接字符串,因此我需要一种方法来覆盖它KeyVault secret 。

最佳答案

目前不支持此功能。请参阅https://github.com/Azure/azure-webjobs-sdk/issues/746

一种方法(提到 here )是使用 ARM 模板进行部署并从 KeyVault 注入(inject) key 。

关于azure - 如何使用 Key Vault key 作为连接字符串来绑定(bind) Azure Functions 中的事件中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51612821/

相关文章:

asp.net-mvc - 使用自定义参数将多个域重定向到同一个 Azure 网站

git push --mirror 自动添加指向不正确工作项的链接

azure - Azure 服务总线触发功能的超时是多少?

.net - Azure Function .net 框架

.net - 带有 Azure Key Vault 的 PKI

Azure Webjob 按计划运行选项缺失

ios - Xamarin iOS 版本构建失败

azure - 使用 DeviceLifecycleEvents 源的 IoT 中心消息路由不起作用

python-3.x - 在 httptrigger 中获取 Keyvault Secret 并使用它来获取要由 Function-Python 输出的信息

c# - 客户端地址未经授权,并且调用者不是 Azure 中的受信任服务