我有一个由事件网格触发的 Azure 函数 (C#)。我在本地调试我的函数时遇到困难,因为它只能通过事件网格触发。
我不确定是否有办法将事件网格连接到我的函数的本地主机地址?我尝试过使用 Web Hook,但它只支持 HTTPS,而我的本地主机使用 HTTP。
public static void Run([EventGridTrigger]EventGridEvent eventGridEvent, ILogger log)
{
ID = eventGridEvent.Subject;
log.LogInformation($"ID: {ID.ToString()}");
}
如有任何建议,我们将不胜感激。
最佳答案
我发现这篇博文帮助我在本地调试事件网格 azure 函数时解决了这个问题:https://blog.mcilreavy.com/articles/2018-12/debug-eventgrid-triggered-azure-function (Web archive link)
我的案例中缺少的一个部分是 aeg-event-type header 。
aeg-event-type:通知
添加后,我可以使用此网址进行本地调试:
http://localhost:7071/runtime/webhooks/EventGrid?functionName=nameOfYourFunction
并在请求正文中包含此事件 json,如下所示:
[ { "id": "'1", "eventType": "yourEventType", "eventTime":"10:59:00.000", "subject": "subject1", "data":{ "make": "杜卡迪", "model": "Monster"}, "dataVersion": "1.0"} ]
关于c# - 调试使用事件网格触发的 Azure 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58977730/