azure-eventgrid - 为 Azure 函数创建 EvenGridSubscription 时尝试验证提供的端点失败
问题描述
我正在尝试为使用EventGridTrigger的 Azure 函数创建 EventGridSubscription。运行New-AzureRmEventGridSubscription cmdlet 时,我看到以下错误:
网址验证:尝试验证提供的端点https://blablafunction.azurewebsites.net/admin/EventGridExtensionConfig失败。
这是天蓝色的功能代码:
[FunctionName("BlobCreatedHandler")]
public static async Task Run([EventGridTrigger]JObject blobEvent,
[Queue("blob-created-queue", Connection = Strings.StorageAccountConnection)] CloudQueue blobCreatedQueue,
[Inject(typeof(IBlobCreatedHandler))] IBlobCreatedHandler blobCreatedHandler)
{
await blobCreatedHandler.Handle(blobEvent, blobCreatedQueue);
}
我尝试了不同版本的 AzureRM.EventGrid 模块。有趣的是,在低于 0.3.0 的版本上它可以正常工作。但是从 0.3.1 开始的所有最新版本都因此错误而失败。有人有同样的经历吗?
UPD: Fiddler 说两个版本的 SDK(好的版本和坏版本)都发送完全相同的请求:
{
"properties": {
"destination": {
"endpointType": "WebHook",
"properties": {
"endpointUrl": "https://blobmalwarescanapptest.azurewebsites.net/admin/EventGridExtensionConfig?functionName=TestFunc&code=PhWghMXtSma188UQccaoErA4Eiw7ygudguHkpq1V0XKMfzA59yBR5g=="
}
},
"filter": {
"includedEventTypes": [
"All"
],
"isSubjectCaseSensitive": false
}
}
并得到完全相同的回应。但是在较新版本的 SDK 上,Azure EventGrid 管理端点似乎会截断“?”之后的所有内容。签名并尝试验证基本 url(没有查询参数)。
解决方案
我刚刚使用 ARM 模板来实现相同的结果。对我有用的端点是:
https://<FunctionAppName>.azurewebsites.net/runtime/webhooks/EventGrid?functionName=<functionName>&code=<code>
虽然这也适用于 azure 函数的 v2,但我看到您正在使用 v1(因为 JObject 作为 eventgrid 触发器)。
编辑:我的 ARM 模板示例:
{
"type": "Microsoft.Storage/storageAccounts/providers/eventSubscriptions",
"name": "[concat(variables('MobileStorageName'), '/Microsoft.EventGrid/', variables('EventSubscriberName'))]",
"apiVersion": "2018-01-01",
"dependsOn": [
"[variables('MobileStorageName')]"
],
"tags": {
"displayName": "Storage Account Event Subscription"
},
"properties": {
"destination": {
"endpointType": "WebHook",
"properties": {
"endpointUrl": "[variables('FunctionAppEndpoint')]"
}
},
"filter": {
"subjectBeginsWith": "",
"subjectEndsWith": "",
"isSubjectCaseSensitive": false,
"includedEventTypes": [ "Microsoft.Storage.BlobCreated" ]
}
}
}
请注意,在我的情况下,我需要 StorageV2(它是 2018-02-1 api),否则它不起作用。
推荐阅读
- mule - 需要使用 Mule esb 在任何地方集成自动化
- jquery - 如何使用 DATETIMEPICKER 按日期过滤 HTML 表?
- android - 我可以从折线对象中找到所有点吗?
- javascript - 代码片段在 Firebase Cloud Functions 中的函数完成后执行
- python - 创建一个没有唯一名称的临时文件夹(python - tempfile)
- python-sphinx - 避免 sphinx 中的换行符
- asp.net - 没有看到我创建的输入字段和下拉列表
- amazon-web-services - S3 的 Lambda 仅触发一次
- django - 如何在 Django 通用视图中生成 PDF?
- java - 使用 Gluon 获取设备信息的问题