gpt4 book ai didi

azure - 通过 ARM 创建对自定义事件网格主题的存储队列订阅

转载 作者:行者123 更新时间:2023-12-03 02:45:09 25 4
gpt4 key购买 nike

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

在门户中导航时这很容易做到,但我无法为此创建适当的 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 block ,这是有道理的。

最佳答案

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

{
"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"
}
}
]
}
}
},

关于azure - 通过 ARM 创建对自定义事件网格主题的存储队列订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59213904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com