【发布时间】:2020-12-08 18:34:28
【问题描述】:
我有一个由 http 触发的简单 azure 函数
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
context.res = {
// status: 200, /* Defaults to 200 */
body: "Success"
};
}
函数.json
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
此时我可以触发函数并查看响应。
然后我尝试将服务总线绑定添加到 function.json
{
"bindings": [
...
{
"type": "serviceBus",
"direction": "out",
"name": "outputSbTopic",
"topicName": "topicName",
"connection": "ServiceBusConnection"
}
]
}
当我添加绑定时,函数返回 404 并且日志中没有任何内容。我什至还没有开始使用绑定。
有什么问题吗?我在这个问题上苦苦挣扎了 2 个多小时,没有更多的想法。
host.json(以防万一)
{
"version": "2.0",
"extensions": {
"serviceBus": {
"prefetchCount": 100,
"messageHandlerOptions": {
"autoComplete": true,
"maxConcurrentCalls": 32,
"maxAutoRenewDuration": "00:05:00"
}
}
}
}
运行时版本 ~2
Node.js 版本 Node.js 12 LTS
应用程序从包文件以只读模式运行。
AppType 函数AppLinux
更新 我使用 VS Code Azure Function Extension 创建了该函数,并使用 DevOps 进行了部署。后来我在 azure 门户中手动创建了函数。与两个函数的应用服务编辑器文件比较,发现我的第一个函数在 host.json 中没有 extensionBundle。这就是原因。
【问题讨论】:
标签: node.js azure-functions azureservicebus