在 Azure 函数中接收来自 Azure.Messaging.EventGrid 的 EventGridEvent

Receive EventGridEvent from Azure.Messaging.EventGrid in Azure function

从 Microsoft.Azure.EventGrid 包切换到 Azure.Messaging.EventGrid 后,以下签名被破坏:

[FunctionName("MyFuncEG")]
public Task RunEventGrid([EventGridTrigger] EventGridEvent data)

出现此异常消息:

Unable to find a constructor to use for type Azure.Messaging.EventGrid.EventGridEvent. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path '[0].topic'

我读了这个 post 想知道是否有任何更新?我应该使用 CloudEvent(这有它的注意事项吗?)还是我需要为 EventGridEvent 编写我的自定义类型,如 post 或其他内容中所述?感谢您的任何输入。

Microsoft.Azure.WebJobs.Extensions.EventGrid 包也应该更新。在我的例子中,我将它更新为 Version="3.0.0-beta.3" 并且它开始工作了。