gpt4 book ai didi

Azure Function EventHubTriggerAttribute 不使用 local.settings.json 中的事件中心名称

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

我遇到的问题是我的 EventHubTriggerAttribute 不再使用 local.settings.json 文件来填充属性中的事件中心名称。这是我收到的错误:

enter image description here

在上面的错误中,它正在寻找ddhubnamespace.servicebus.windows.net/eventhubname,它实际上应该是ddhubnamespace.servicebus.windows.net/ddhub

这是此处 TriggerAttribute 中的事件中心名称:

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

这是使用 local.settings.json 文件,我必须从这里获取 eventHubName:

{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_EXTENSION_VERSION": "~1",
"eventHubConnection": "Endpoint=sb://ddhubnamespace.servicebus.windows.net/;...",
"eventHubName": "ddhub",

如果在属性内,我将“eventHubName”切换为 local.settings.json 中的实际事件中心名称(“ddhub”)。该函数将成功运行。此外,将属性中的 Connection 属性设置为 json 名称将从 json 中获取值。知道为什么我的 eventhubname 不再从 json 中提取,而是将其视为文字字符串吗?

最佳答案

要从配置文件中获取值,您应该在属性参数中用 % 标记它:

[EventHubTrigger("%eventHubName%", Connection = "eventHubConnection")]

关于Azure Function EventHubTriggerAttribute 不使用 local.settings.json 中的事件中心名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46697659/

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