ARM嵌套模板“无效的模板找不到模板资源”

时间:2019-06-13 19:41:24

标签: azure deployment nested azure-resource-manager arm-template

我正在部署手臂模板,以为现有的流量管理器创建SSL证书,并将证书绑定到应用程序服务。 由于应用程序服务位于一个资源组中,而流量管理器和证书位于另一个资源组中,因此我使用嵌套模板。 我的证书SSL错误:

  

部署模板验证失败:“模板参考   'blabla-ssl1'无效:找不到模板资源或   具有该名称的资源副本

  "comments": "Get the Traffic Manager SSL cert that will be binded to the app",
  "copy": {
    "name": "loop",
    "count": "[length(variables('locations'))]"
  },
  "type": "Microsoft.Web/certificates",
  "name": "[concat(variables('tmsslcert')['secretname'], copyIndex())]",
  "apiVersion": "2016-03-01",
  "location": "[variables('locations')[copyIndex()]]",
  "dependsOn": [
    "[variables('TMName')]"
  ],
  "properties": {
    "keyVaultId": "[variables('tmsslcert')['KeyVaultId']]",
    "secretname": "[variables('tmsslcert')['secretname']]"
  }
},
{
  "type": "Microsoft.Resources/deployments",
  "apiVersion": "2018-05-01",
  "resourceGroup": "[variables('webappResourceGroup')]",
  "name": "[concat('AddTMSSLCert_',variables('locations')[copyIndex()],'_nestedTemplate')]",
  "copy": {
    "name": "endpointloop",
    "count": "[length(variables('locations'))]"
  },
  "properties": {
    "mode": "Incremental",
    "template": {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "comments": "app hostname binding of TM CNAME",
          "type": "Microsoft.Web/sites/hostNameBindings",
          "name": "[concat(variables('webappDNSNamePrefix'), '-', variables('locations')[copyIndex()], '/', variables('tmcname'))]",
          "apiVersion": "2016-08-01",
          "location": "[variables('locations')[copyIndex()]]",
          "scale": null,
          "properties": {
            "siteName": "variables('webappDNSNamePrefix'), '-', variables('locations')[copyIndex()]",
            "sslState": "SniEnabled",
            "thumbprint": "[reference(resourceId(variables('webappResourceGroup'),'Microsoft.Web/certificates', concat(variables('tmsslcert')['secretname'], copyIndex())),'2016-03-01').Thumbprint]"
          },
          "dependsOn": [
            "[concat(variables('tmsslcert')['secretname'], copyIndex())]",
            //"[concat('Microsoft.Web/certificates/', variables('tmsslcert')['secretname'], copyIndex())]"
          ]
        }
      ]
    }
  }
}

1 个答案:

答案 0 :(得分:1)

(根据您提供的数据)无法确定错误的确切位置,但这意味着您的referencesdependsOn正在尝试访问未创建的资源或其他资源资源组。看起来特别错误的一件事是:

"dependsOn": [
    "[concat(variables('tmsslcert')['secretname'], copyIndex())]",
    //"[concat('Microsoft.Web/certificates/', variables('tmsslcert')['secretname'], copyIndex())]"
]

这是行不通的,因为它将在嵌套部署的上下文中工作,因此在另一个资源组中

相关问题