【问题标题】:Creating storage queue subscription to custom Event Grid Topic via ARM通过 ARM 创建对自定义事件网格主题的存储队列订阅
【发布时间】:2020-03-31 11:48:38
【问题描述】:

我正在尝试从自定义主题为我的存储队列设置事件网格订阅。

在门户中导航时很容易做到这一点,但我无法为此创建适当的 ARM 模板。经过大量搜索和尝试,我想出了以下模板。

{
    "name": "MyCustomTopicName/Microsoft.EventGrid/MySubscriptionName",
    "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
    "location": "[resourceGroup().location]",
    "apiVersion": "2019-06-01",
    "properties": {
        "destination": {
            "endpointType": "StorageQueue",
            "properties": {
                "resourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('theNameOfMyStorageAccount'))]",
                "queueName": "[variables('theNameOfMyQueue')]"
            }
        },
        "filter": {
            "advancedFilters": []
        },
        "labels": [],
        "eventDeliverySchema": "EventGridSchema"
    }
}

这在我看来相当不错,但失败了,因为事件网格主题不在我将模板部署到的资源组中。

Deployment failed. Correlation ID: [guid]. {
  "error": {
    "code": "ResourceNotFound",
    "message": "The Resource 'Microsoft.EventGrid/topics/MyCustomTopicName' under resource group 'TheResourceGroupTheStorageAccountIsIn' was not found."
  }
}

我正在将完整的 ARM 模板部署到 TheResourceGroupTheStorageAccountIsInMyCustomTopicName 主题位于我们放置自定义主题的资源组中,因此所有服务都可以使用它。

我尝试使用自定义主题的完整标识符(资源 ID),但这无效。想法?

PS:我正在使用类似的模板来创建 Azure Functions 的订阅,它确实可以正常工作。那里的主要区别是destination 块,这是有道理的。

【问题讨论】:

  • 能否分享一个用于针对函数部署订阅的 ARM 模板的 sn-p 吗?

标签: azure arm-template azure-eventgrid


【解决方案1】:

如果我没看错,您只需要使用嵌套部署并定位主题所在的资源组:

{
    "apiVersion": "2017-05-10",
    "name": "nestedTemplate",
    "type": "Microsoft.Resources/deployments",
    "resourceGroup": "your_topic_resource_roup",
    "properties": {
        "mode": "Incremental",
        "template": {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
                {
                    "name": "MyCustomTopicName/Microsoft.EventGrid/MySubscriptionName",
                    "type": "Microsoft.EventGrid/topics/providers/eventSubscriptions",
                    "location": "[resourceGroup().location]",
                    "apiVersion": "2019-06-01",
                    "properties": {
                        "destination": {
                            "endpointType": "StorageQueue",
                            "properties": {
                                "resourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('theNameOfMyStorageAccount'))]",
                                "queueName": "[variables('theNameOfMyQueue')]"
                            }
                        },
                        "filter": {
                            "advancedFilters": []
                        },
                        "labels": [],
                        "eventDeliverySchema": "EventGridSchema"
                    }
                }
            ]
        }
    }
},

【讨论】:

    猜你喜欢
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2020-05-09
    • 2020-07-18
    • 2019-06-11
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    相关资源
    最近更新 更多