用于存储帐户Blob的ARM模板创建事件网格订阅

时间:2020-04-06 07:19:43

标签: azure azure-storage arm-template azure-eventgrid azure-template

我在存储帐户上为blob创建的事件创建了一个事件网格订阅。我想使用ARM模板创建相同的东西,但是遇到麻烦。

观察-

  1. 运行以下模板,将在资源组而不是存储帐户上创建事件网格订阅。
  2. 根据问题#563和#455,应将提供程序用作类型。但是'providers'类型在apiversion“ 2020-04-01-preview”中无效。
{
      "name": "[parameters('blobcreate_eventsubscription_name')]",
      "apiVersion": "2020-04-01-preview",
      "type": "Microsoft.EventGrid/eventSubscriptions",
      "dependsOn": [
      "[variables('storageAccountResourceId')]" //,
     //"[variables('functionAppResourceId')]"
      ],
     "properties": {
        // "topic": "[variables('storageAccountResourceId')]",
        "destination": {
        "endpointType": "AzureFunction",
        "properties": {
           "resourceId": "[variables('azureFunctionResourceId')]",
           "maxEventsPerBatch": 1,
           "preferredBatchSizeInKilobytes": 64
         } 
       },
       "filter": {
       "subjectBeginsWith": "[concat('/blobServices/default/containers', parameters('storageAccounts_blobname'))]",
       "subjectEndsWith": ".xml",
       "includedEventTypes": [
        "Microsoft.Storage.BlobCreated"
       ],
       "advancedFilters": []
     },
     "labels": [],
     "eventDeliverySchema": "EventGridSchema",
     "retryPolicy": {
       "maxDeliveryAttempts": "[parameters('eventgrid_maxDeliveryAttemps')]",
       "eventTimeToLiveInMinutes": "[parameters('eventgrid_eventTimeToLiveInMinutes')]"
     },
     "deadLetterDestination": {
       "endpointType": "StorageBlob",
       "properties": {
          "resourceId": "[variables('storageAccountResourceId')]",
          "blobContainerName": "[parameters('storageAccounts_deadletterblob_name')]"
        }
      }
    }
}

1 个答案:

答案 0 :(得分:1)

这是一个可以使用基础的官方示例:

{
    "type": "Microsoft.Storage/storageAccounts/providers/eventSubscriptions",
    "name": "[concat(parameters('storageName'), '/Microsoft.EventGrid/', parameters('eventSubName'))]",
    "apiVersion": "2018-01-01",
    "dependsOn": [
        "[parameters('storageName')]"
    ],
    "properties": {
        "destination": {
            "endpointType": "WebHook",
            "properties": {
                "endpointUrl": "[parameters('endpoint')]"
            }
        },
        "filter": {
            "subjectBeginsWith": "",
            "subjectEndsWith": "",
            "isSubjectCaseSensitive": false,
            "includedEventTypes": [
                "All"
            ]
        }
    }
}

注意资源的资源类型和名称。

https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-event-grid-subscription-and-storage/azuredeploy.json