【发布时间】:2021-10-13 23:06:12
【问题描述】:
目标是将数据写入 Azure 中的主题,但我收到以下错误:
“PostBooking”函数出错:绑定类型“eventGrid”未注册。请确保类型正确并安装了绑定扩展。
我在本地开发这个。
index.js
module.exports = async function (context, req) {
let booking = req.body;
var timeStamp = new Date().toISOString();
context.bindings.bookings = booking;
context.bindings.outputEvent = {
id: 'message-id'+timeStamp,
subject: 'Booking',
dataVersion: '1.0',
eventType: 'event-type',
data: booking,
eventTime: timeStamp
};
context.res = {
status: 201,
headers: {
"content-type": "application/json"
},
body: {
message: booking.id
}
}
context.done();
}
function.js
{
"disabled": false,
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
],
"route": "bookings/"
},
{
"name": "outputEvent",
"type": "eventGrid",
"topicEndpointUri": "{hidden}",
"topicKeySetting": "{hidden}",
"direction": "out"
},
{
"name": "bookings",
"type": "cosmosDB",
"direction": "out",
"databaseName": "{hidden}",
"collectionName": "bookings",
"createIfNotExists": true,
"connectionStringSetting": "CosmosDB"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
我不知道该怎么办?
【问题讨论】:
-
我已经添加了这个github.com/Azure/azure-functions-eventgrid-extension/issues/…,但它并没有解决问题。其他解决方案是用 .NET 编写的。
-
不加截图,可以加代码吗?很容易复制粘贴。
-
尝试从临时文件夹中删除 FunctionBundles
标签: node.js azure azure-functions serverless azure-eventgrid