azure - 如何在 copyIndex(数组)资源上使用 dependentOn?

标签 azure azure-resource-manager azure-rm-template

我正在使用arm模板来部署主题和订阅。我要部署的资源属于 Microsoft.Resources/deployments 类型,因为我的目标是部署所在位置外部的资源组。

如果主题已存在,则模板可以工作。 由于 Arm 模板资源是并行部署的,因此我需要在订阅之前部署主题 - this ordering is made possible by dependsOn

我遇到的问题是,因为主题的 "name" 值有一个 copyIndex(),我不确定如何可以定位主题资源。

在我尝试过的许多事情中,以下是一些:

  • [concat(parameters('serviceBusNamespaceName'), '/',parameters('subscriptions')[copyIndex()].topic)]
  • [resourceId('Microsoft.Resources/deployments', 参数('主题'))]
  • [“topicLoop”]

以下是我的模板中的主题和订阅资源对象:

        {
            "apiVersion": "2018-02-01",
            "type": "Microsoft.Resources/deployments",
            "name": "[concat(parameters('serviceBusNamespaceName'), copyIndex())]",
            "resourceGroup": "[parameters('sharedResourcesResourceGroupName')]",
            "copy": {
                "name": "topicLoop",
                "count": "[length(parameters('topics'))]"
            },
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "2018-05-01",
                    "contentVersion": "1.0.0.0",
                    "resources": [
                        {
                            "type": "Microsoft.ServiceBus/namespaces/topics",
                            "name": "[concat(parameters('serviceBusNamespaceName'), '/', parameters('topics')[copyIndex()])]",
                            "apiVersion": "2017-04-01",
                            "location": "[resourceGroup().location]",
                            "properties": {}                  
                        }
                    ]
                }
            }
        },
        {
            "apiVersion": "2018-02-01",
            "type": "Microsoft.Resources/deployments",
            "name": "[concat(parameters('subscriptions')[copyIndex()].topic, copyIndex())]",
            "resourceGroup": "[parameters('sharedResourcesResourceGroupName')]",
            "copy": {
                "name": "subscriptionLoop",
                "count": "[length(parameters('subscriptions'))]"
            },
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "2018-05-01",
                    "contentVersion": "1.0.0.0",
                    "resources": [
                        {
                            "type": "Microsoft.ServiceBus/namespaces/topics/subscriptions",
                            "name": "[concat(parameters('serviceBusNamespaceName'), '/', parameters('subscriptions')[copyIndex()].topic, '/', parameters('subscriptions')[copyIndex()].subscription)]",
                            "apiVersion": "2017-04-01",
                            "location": "[resourceGroup().location]",
                            "properties": {}          
                        }
                    ]
                }
            },
            "dependsOn": [
                // what goes here?! I need to have this depend on the topics 
            ]
        }

最佳答案

dependsOn 值很简单:

“dependsOn”:[“topicLoop”]

但它需要位于最外部的资源上,而不是嵌套模板上。

关于azure - 如何在 copyIndex(数组)资源上使用 dependentOn?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58920593/

相关文章:

Azure 逻辑应用程序 - Google 云端硬盘复制文件 - 连接器无法从 Azure 文件共享上传文件

azure - 错误: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template resource

git - 使用 Azure DevOps Git 配置进行 DataFactory 的 Azure ARM 模板部署

azure - 将 ARM 模板部署到 Azure 时出错

azure - 如何使用 ARM 模板为 Azure 资源创建事件日志诊断设置

azure - 在 Azure 移动服务中托管移动应用后端相对于 Azure 网站的优势

azure - 从队列中获取消息仅检索单个消息

azure - Docker 镜像未在 Web 浏览器 Azure Kubernetes 中显示

azure - 使用 ARM 模板创建 Azure 存储队列

azure - 有没有办法使用 ARM 模板创建 Azure 服务主体?