gpt4 book ai didi

Python Azure 函数、EventGrid 触发器

转载 作者:行者123 更新时间:2023-12-03 03:41:03 26 4
gpt4 key购买 nike

我对 azure 还很陌生,并且正在努力处理 eventGrid 中的 python 函数触发器。我正在使用从 azure for python 创建的现成模板并收到错误。我将分享这些文件。

(init.py)

import json
import logging

import azure.functions as func


def main(event: func.EventGridEvent):

result = json.dumps(
{
"id": event.id,
"data": event.get_json(),
"topic": event.topic,
"subject": event.subject,
"event_type": event.event_type,
}
)

logging.info("Python EventGrid trigger processed an event: %s", result)

函数.json

{
"bindings": [
{
"type": "eventGridTrigger",
"name": "event",
"direction": "in"
}
],
"disabled": false,
"scriptFile": "__init__.py"
}

主机.json

{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
}

这就是我发送到事件网格的数据集

{
"topic": "/subscriptions/{subscriptionID}/resourcegroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/event",
"subject": "eventhubs/test",
"eventType": "captureFileCreated",
"eventTime": "2017-07-14T23:10:27.7689666Z",
"id": "{id}",
"data": {
"fileUrl": "https://test.blob.core.windows.net/debugging/testblob.txt",
"fileType": "AzureBlockBlob",
"partitionId": "1",
"sizeInBytes": 0,
"eventCount": 0,
"firstSequenceNumber": -1,
"lastSequenceNumber": -1,
"firstEnqueueTime": "0001-01-01T00:00:00",
"lastEnqueueTime": "0001-01-01T00:00:00"
},
"dataVersion": "",
"metadataVersion": "1"
}

我得到的错误是

fail: Function.{functionName}[3]
Executed 'Functions.{functionName}' (Failed, Id={someID}, Duration=121ms)
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.{functionName}
System.InvalidOperationException: Exception binding parameter 'event'
System.NotImplementedException: The method or operation is not implemented.

可能这是上面某个地方非常简单的错误,但我找不到它..

提前致谢!

最佳答案

python fail: Function.{functionName}[3] Executed 'Functions.{functionName}' (Failed, Id={someID}, Duration=121ms) Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.{functionName} System.InvalidOperationException: Exception binding parameter 'event' System.NotImplementedException: The method or operation is not implemented.

上述错误是非常常见的通用错误消息。当您的应用程序遇到事件网格的某些限制时,它就会出现。

如果达到事件网格限制的最大点击数,请参阅 this

Note: Event Grid triggers aren't natively supported in an internal load balancer App Service Environment. The trigger uses an HTTP request that can't reach the function app without a gateway into the virtual network.

如果您使用消费计划,请尝试使用专用计划以避免此问题。

请参阅reliable event processing关联此错误。

检查事件网格的限制并选择适合您的要求的计划。

引用:

azure 函数因函数调用而失败 exception

关于Python Azure 函数、EventGrid 触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71250651/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com