gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:30:48 26 4
gpt4 key购买 nike

我为 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com