Azure Function EventHubTriggerAttribute不使用来自local.settings.json的事件集线器名称
问题描述:
我遇到问题,其中我的EventHubTriggerAttribute不再使用我的local.settings.json文件在属性中填充事件集线器名称。这是我得到的错误:Azure Function EventHubTriggerAttribute不使用来自local.settings.json的事件集线器名称
在它正在寻找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",
如果在属性中,我将local.settings.json(“ddhub”)中实际事件中心名称的“eventHubName”切换出来。该功能将成功运行。另外,将属性设置为json名称的Connection属性将从json中获取值。任何想法,为什么我的eventhubname不再从json拉,而是把它作为一个文字字符串?
答
要采取从配置文件中的值,你应该在属性参数与%
标记它:
[EventHubTrigger("%eventHubName%", Connection = "eventHubConnection")]
谢谢你,你光荣的人!在我的代码更改中,必须删除该代码。 – Shawn