我在下面有ARM模板,有时会抛出异常,告诉我依赖于Extension不能正常工作,因为扩展只能在父虚拟机启动时部署。我究竟做错了什么?
这里有整个模板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."
}
}
除了4c74356b41的响应,你可以设置依赖关系并检查参考函数,如下所述 - > https://docs.microsoft.com/bs-cyrl-ba/azure/azure-resource-manager/resource-manager-not-found-errors
您可以设置所需的依赖项并为Microsoft.EnterpriseCloud.Monitoring扩展和资源组设置参考,并尝试一下。