gpt4 book ai didi

Azure Function EventHubTrigger 属性未找到事件中心名称

转载 作者:行者123 更新时间:2023-12-03 03:03:34 24 4
gpt4 key购买 nike

我遇到一个问题,当我将函数发布到函数应用程序时,找不到我的事件中心名称(如果我只是在 VS2017 中运行它,它在本地运行良好)。当我打开 Azure 门户中已发布的函数时,我收到以下错误。

enter image description here

这是我的 Run 方法的属性。

public static void Run([EventHubTrigger("%eventHubName%", Connection = "eventHubConnection")]string data, TraceWriter log)

现在,如果我不包含包含在 eventHubName 周围的 %,当我在本地运行它时,它会说它找不到 eventhub (字面上使用 eventHubName 字符串而不是查看 local.settings。 json(如连接字符串),但发布后即可使用。我想避免将实际名称放入属性中,因为不同的环境将具有唯一的事件中心名称。

最佳答案

在本地开发时,Azure Functions 将使用 local.settings.json 文件。当您的 Function App 在 Azure 上运行时,它将从应用程序设置中读取值。

使用 %zzz% 是读取设置的正确方法,因此这让我怀疑当您部署到 Azure 时,应用程序设置中是否有名为 eventHubName 的设置.

https://learn.microsoft.com/en-us/azure/app-service/web-sites-configure

关于Azure Function EventHubTrigger 属性未找到事件中心名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46736911/

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