使用功能端点上的ARM创建Eventgrid订阅

问题描述 投票:0回答:1

我正在尝试使用ARM模板在Azure存储帐户上创建Eventgrid订阅。在门户中手动创建它并进入高级设置,产生了以下模板。我进一步向其中添加了所需的模板项目(例如架构),但它始终会产生错误。我尝试过在网上寻找类似的模板,但似乎无法使用"endpointType": "AzureFunction"找到任何模板。此外,在资源浏览器中也没有提到可以进一步帮助我的部署。

任何人都可以帮助我解决问题吗?

从门户创建期间生成的模板:

{
    "name": "test123",
    "properties": {
        "topic": "/subscriptions/<guid>/resourceGroups/<myGroup>/providers/Microsoft.Storage/storageAccounts/<myStorageAccount>",
        "destination": {
            "endpointType": "AzureFunction",
            "properties": {
                "resourceId": "/subscriptions/<guid>/resourceGroups/<myGroup>/providers/Microsoft.Web/sites/<myFunctionsApp>/functions/<myFunction>",
                "maxEventsPerBatch": 1,
                "preferredBatchSizeInKilobytes": 64
            }
        },
        "filter": {
            "includedEventTypes": [
                "Microsoft.Storage.BlobCreated"
            ],
            "advancedFilters": [
                {
                    "operatorType": "StringContains",
                    "key": "Subject",
                    "values": [
                        "-original"
                    ]
                }
            ]
        },
        "labels": [],
        "eventDeliverySchema": "EventGridSchema"
    }
}

完整模板:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    },
    "resources": [
        {
            "name": "test123",
            "type": "Microsoft.EventGrid/eventSubscriptions",
            "apiVersion": "2020-01-01-preview",
            "location": "westeurope",
            "properties": {
                "topic": "/subscriptions/<guid>/resourceGroups/<myGroup>/providers/Microsoft.Storage/storageAccounts/<myStorageAccount>",
                "destination": {
                    "endpointType": "AzureFunction",
                    "properties": {
                        "resourceId": "/subscriptions/<guid>/resourceGroups/<myGroup>/providers/Microsoft.Web/sites/<myFunctionsApp>/functions/<myFunction>",
                        "maxEventsPerBatch": 1,
                        "preferredBatchSizeInKilobytes": 64
                    }
                },
                "filter": {
                    "includedEventTypes": [
                        "Microsoft.Storage.BlobCreated"
                    ],
                    "advancedFilters": [
                        {
                            "operatorType": "StringContains",
                            "key": "Subject",
                            "values": [
                                "-original"
                            ]
                        }
                    ]
                },
                "labels": [
                ],
                "eventDeliverySchema": "EventGridSchema"
            }
        }
    ]
}

错误:

指定的主题属性与事件订阅范围中的预期主题不匹配

azure azure-resource-manager azure-eventgrid
1个回答
0
投票

我不认为endpointType中的AzureFunctiondocumented是分开的。这只是webhook处理程序的特例。

GitHub Repo包含示例ARM模板,您可以参考。这是您需要的确切代码段

...
"destination": {
    "endpointType": "WebHook",
    "properties": {
        "endpointUrl": "[concat(variables('functionUrl'), listKeys(resourceId('Microsoft.Web/sites/host/', variables('functionAppName'), 'default'),'2016-08-01').systemkeys.eventgrid_extension)]"
    }
}
...
© www.soinside.com 2019 - 2024. All rights reserved.