【问题标题】:ARM nested template ‘Invalid Template could not find template resource’ARM 嵌套模板“无效模板找不到模板资源”
【发布时间】:2019-10-28 11:10:25
【问题描述】:

我正在部署 arm 模板来为现有流量管理器创建 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())]"
          ]
        }
      ]
    }
  }
}

【问题讨论】:

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


    【解决方案1】:

    无法准确判断错误在哪里(根据您提供的数据),但这意味着您的 referencesdependsOn 正在尝试访问未创建的资源或位于不同资源组中的资源。看起来特别错误的一件事是:

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

    这不起作用,因为它将在嵌套部署的上下文中工作,因此在不同的资源组中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多