我正在尝试创建一个函数,当消息在 Azure 服务总线订阅中可用时触发。我遵循了官方文档中的简短示例。
通过本地运行应用程序func host start
会导致以下错误:“ServiceBusTriggerJS:未注册绑定类型'serviceBusTrigger'。请确保类型正确并安装了绑定扩展。 ”
我的设置:
package.json
包含 azure 节点模块:"azure": "^2.2.1-preview"
. 节点版本为 8.11。
function.json
如示例中所示:
{
"disabled": false,
"bindings": [
{
"topicName": "myTopic",
"subscriptionName": "mySubscription",
"connection": "MyServiceBus",
"name": "myQueueItem",
"type": "serviceBusTrigger",
"direction": "in"
}
]
}
local.settings.json
包含到服务总线的连接字符串和本地运行所需的存储帐户:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=...",
"MyServiceBus": "Endpoint=sb://...servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=..."
}
}
index.js
也与示例相同:
module.exports = function (context, myQueueItem) {
context.log('JavaScript queue trigger function processed work item', myQueueItem);
context.done();
};
编辑:这类似于这个问题:绑定类型 'serviceBusTrigger' is not registered error in azure functions c# with core tools 2。问题(以及解决方案)是相同的。我在这里找到了直接实施的答案。