子资源中正确的依赖项分配似乎不起作用

时间:2019-03-15 14:43:34

标签: azure-resource-manager

我有一个ARM模板,下面有时会引发异常,该异常告诉我Extension中的依赖项无法正常工作,因为只能在父VM启动时才部署扩展。我在做什么错了?

整个模板在此处http://pastebin.com/VyDwGWWd

          {
            "apiVersion": "2018-10-01",
            "type": "Microsoft.Compute/virtualMachines",
            "name": "[concat('Lin', parameters('VirtualMachineName'), copyindex())]",
            "copy": {
              "name": "LinvirtualMachineLoop",
              "count": 3
            },
            "location": "[variables('VMResourceGroupLocation')]",
            "dependsOn": [
                "LinnicLoop",
                "[variables('LogAnalyticsName')]",
                "LinuxMachinesAvailabilitySet"
            ],
            "properties": {
                "availabilitySet": {
                    "id": "[resourceId('Microsoft.Compute/availabilitySets','LinuxMachinesAvailabilitySet')]"
        },
              "hardwareProfile": {
                "vmSize": "Standard_D4s_v3"
              },
              "osProfile": {
                "computerName": "[concat('Lin', parameters('VirtualMachineName'), copyindex())]",
                "adminUsername": "[parameters('adminUsername')]",
                "adminPassword": "[parameters('adminPassword')]"
              },
              "storageProfile": {
                "imageReference": "[variables('linuxImage')]",
                "osDisk": {
                  "createOption": "FromImage"
                }
              },
              "networkProfile": {
                "networkInterfaces": [
                  {
                    "id": "[resourceId('Microsoft.Network/networkInterfaces',concat('Linnic',copyindex()))]"
                  }
                ]
              }
            },
            "resources": [
        {
          "type": "extensions",
          "name": "Microsoft.EnterpriseCloud.Monitoring",
          "apiVersion": "2017-03-30",
          "location": "[variables('VMResourceGroupLocation')]",
          "dependsOn": [
           "[concat('Microsoft.Compute/virtualMachines/', concat('Lin', parameters('VirtualMachineName'), copyindex()))]"
          ],
          "properties": {
            "publisher": "Microsoft.EnterpriseCloud.Monitoring",
            "type": "OmsAgentForLinux",
            "typeHandlerVersion": "1.6",
            "autoUpgradeMinorVersion": true,
"settings": {
              "workspaceId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces/', variables('LogAnalyticsName')), '2015-03-20').customerId]"
            },
            "protectedSettings": {
              "workspaceKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces/', variables('LogAnalyticsName')), '2015-03-20').primarySharedKey]"
            }
          }
        }
      ]


            },

错误

{
  "error": {
    "code": "ResourceNotFound",
    "message": "The Resource 'Microsoft.Compute/virtualMachines/LinWKDEMO0/extensions/Microsoft.EnterpriseCloud.Monitoring' under resource group 'WKDemo' was not found."
  }
}

1 个答案:

答案 0 :(得分:0)

除了4c74356b41的响应之外,您还可以按照下面的说明设置依赖性并检查引用函数-> https://docs.microsoft.com/bs-cyrl-ba/azure/azure-resource-manager/resource-manager-not-found-errors

您可以设置必需的依赖项,并为Microsoft.EnterpriseCloud.Monitoring扩展以及资源组设置参考,然后尝试一下。