我有一个Azure函数,其中blobTrigger
作为输入,Azure Storage Table
作为输出。它可以正常工作。
现在,我尝试添加事件网格主题作为函数中的绑定输出。
这是新的fuction.json
(添加了一个新的eventGrid):
{
"bindings": [
{
"type": "blobTrigger",
"direction": "in",
"name": "landedFile",
"path": "landing/{name}",
"connection": "AZURE_STORAGE_CONNECTION_STRING"
},
{
"type": "table",
"direction": "out",
"name": "xxTable",
"tableName": "xxTable",
"connection": "AZURE_STORAGE_CONNECTION_STRING"
},
{
"type": "eventGrid",
"direction": "out",
"name": "xxEvent",
"topicEndpointUri": "AZURE_TOPIC_XX_ENDPOINT",
"topicKeySetting": "AZURE_TOPIC_XX_KEY"
}
]
}
AZURE_TOPIC_XX_ENDPOINT
的值为:
az eventgrid topic show \
--name $topicName \
--resource-group $resourceGroupName \
--query endpoint \
--output tsv
AZURE_TOPIC_XX_KEY
的值为:
az eventgrid topic key list \
--name $topicName \
--resource-group $resourceGroupName \
--query key1 \
--output tsv
我仔细检查了key1
是键之一。
我发布的应用没有任何错误,但是:
[请帮助。我不知道可能是什么问题,或者在哪里可以找到任何线索或错误消息。
我发现有人在这里遇到相同的问题:https://github.com/MicrosoftDocs/azure-docs/issues/48921
这里问题的根源是Microsoft提供的ExtensionBundle
没有eventGrid
输出绑定,只有eventGrid
trigger绑定。这导致eventGrid
输出绑定不包含在捆绑软件中。因此,您的错误。我可以看到它已在最新版本1.2.0+中添加,但似乎尚未发布。
同时,我建议您要做的就是通过简单地发布到EventGrid来解决此问题。这是使用Node.js的示例。
await axios.post(process.env["EventGridEndpoint"], ceEvent.format(), {
headers: {
'aeg-sas-key': process.env["EventGridKey"],
'Content-Type': 'application/cloudevents+json'
}
});
EventGridEndpoint
属性可以在您创建的EventGrid主题的摘要页面上获得,EventGridKey
在关键部分下面。
您可以在此处直接查看如何使用EventGrid的完整Microsoft文档:https://docs.microsoft.com/en-us/azure/event-grid/edge/api
最后,在添加EventGrid out绑定后未触发功能的原因是,该错误现在是主机级错误,可以加载和执行功能。您可以通过转到Application Insights并运行以下查询来调试它:
traces
| where message contains "eventGrid"
您将看到类似这样的内容:
The 'xxxxx' function is in error: The binding type(s) 'eventGrid' are not registered. Please ensure the type is correct and the binding extension is installed.