我正在尝试将新VM部署到新资源组中。我用于VM的NIC将属于新资源组,并且将与来自另一个资源组中的VNet的子网相关联。 (目前这是在Azure中运行的,我已经导出了一个模板,正在努力将其修复到工作状态,以便将来重新部署)
这是我尝试部署时收到的错误的副本: Screenshot of error
部署模板验证失败:'资源' Microsoft.Network/virtualNetworks/prod-vnet/subnets/devSnDb'未在模板中定义。有关使用详情,请参阅https://aka.ms/arm-template。'。 (代码:InvalidTemplate)
这是我正在处理的JSON模板的副本。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"availabilitySets_dev_bi_as_name": {
"defaultValue": "dev-bi-as",
"type": "String"
},
"virtualMachines_dev_bi_vm1_name": {
"defaultValue": "dev-bi-vm1",
"type": "String"
},
"loadBalancers_devSnDb_bi_lb_name": {
"defaultValue": "devSnDb-bi-lb",
"type": "String"
},
"networkInterfaces_dev_bi_vm1_nic1_name": {
"defaultValue": "dev-bi-vm1-nic1",
"type": "String"
},
"publicIPAddresses_dev_bi_vm1_pip_name": {
"defaultValue": "dev-bi-vm1-pip",
"type": "String"
},
"storageAccounts_devbivm1st0_name": {
"defaultValue": "devbivm1st0",
"type": "String"
},
"extensions_BGInfo_name": {
"defaultValue": "dev-bi-vm1/BGInfo",
"type": "String"
},
"loadBalancer_InboundNAT_RDP": {
"defaultValue": "nat-rdp",
"type": "string"
},
"loadBalancers_devSnDb_bi_lb_id": {
"defaultValue": "/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Network/loadBalancers/devSnDb-bi-lb/frontendIPConfigurations/devSnDblb-frontend",
"type": "String"
},
"existing_vnet_name": {
"defaultValue": "prod-vnet",
"type": "string"
},
"existing_subnet_name": {
"defaultValue": "devSnDb",
"type": "string"
},
"virtualNetworkResourceGroup": {
"defaultValue": "prod-networking-rg",
"type": "string"
},
"networkInterfaces_dev_bi_vm1_nic1_id": {
"defaultValue": "/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/prod-networking-rg/providers/Microsoft.Network/virtualNetworks/prod-vnet/subnets/devSnDb",
"type": "String"
}
},
"variables": {
"LbNatRDPRuleName": "[concat(parameters('virtualMachines_dev_bi_vm1_name'), '-', parameters('loadBalancer_InboundNAT_RDP'))]",
"LbResourceId": "[resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_devSnDb_bi_lb_name'))]",
"InboundNatRuleRDPResourceId": "[concat(variables('LbResourceId'), '/inboundNatRules/', variables('LbNatRDPRuleName'))]",
"vnetResourceId": "[resourceId(parameters('virtualNetworkResourceGroup'),'Microsoft.Network/virtualNetworks', parameters('existing_vnet_name'))]",
"subnetResourceId": "[concat(variables('vnetResourceID'),'/subnets/', parameters('existing_subnet_name'))]",
"frontEndIpConfigId": "[concat(variables('LbResourceId'), '/frontendIPConfigurations/devSnDblb-frontend')]"
},
"resources": [{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Compute/availabilitySets/dev-bi-as'.",
"type": "Microsoft.Compute/availabilitySets",
"sku": {
"name": "Classic"
},
"name": "[parameters('availabilitySets_dev_bi_as_name')]",
"apiVersion": "2016-04-30-preview",
"location": "australiaeast",
"scale": null,
"properties": {
"platformUpdateDomainCount": 5,
"platformFaultDomainCount": 3,
"virtualMachines": [{
"id": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachines_dev_bi_vm1_name'))]"
}]
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Compute/virtualMachines/dev-bi-vm1'.",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('virtualMachines_dev_bi_vm1_name')]",
"apiVersion": "2016-04-30-preview",
"location": "australiaeast",
"scale": null,
"properties": {
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySets_dev_bi_as_name'))]"
},
"hardwareProfile": {
"vmSize": "Standard_D11"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"osType": "Windows",
"name": "OS",
"createOption": "FromImage",
"vhd": {
"uri": "[concat('https', '://', parameters('storageAccounts_devbivm1st0_name'), '.blob.core.windows.net', concat('/vhds/', parameters('virtualMachines_dev_bi_vm1_name'),'-disk0.vhd'))]"
},
"caching": "ReadWrite"
},
"dataDisks": [{
"lun": 0,
"name": "Data",
"createOption": "Empty",
"vhd": {
"uri": "[concat('https', '://', parameters('storageAccounts_devbivm1st0_name'), '.blob.core.windows.net', concat('/vhds/', parameters('virtualMachines_dev_bi_vm1_name'),'-disk1.vhd'))]"
},
"caching": "None",
"diskSizeGB": 1023
}]
},
"osProfile": {
"computerName": "[parameters('virtualMachines_dev_bi_vm1_name')]",
"adminUsername": "foo_admin",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
},
"secrets": []
},
"networkProfile": {
"networkInterfaces": [{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_dev_bi_vm1_nic1_name'))]"
}]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('https', '://', parameters('storageAccounts_devbivm1st0_name'), '.blob.core.windows.net', '/')]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySets_dev_bi_as_name'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccounts_devbivm1st0_name'))]",
"[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_dev_bi_vm1_nic1_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Network/loadBalancers/devSnDb-bi-lb'.",
"type": "Microsoft.Network/loadBalancers",
"name": "[parameters('loadBalancers_devSnDb_bi_lb_name')]",
"apiVersion": "2017-06-01",
"location": "australiaeast",
"scale": null,
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "7c725cf2-3995-4a59-8f13-c4d461c641fe",
"frontendIPConfigurations": [{
"name": "devSnDblb-frontend",
"etag": "W/\"a76fdd2a-96d9-4f76-9fa5-87699235647f\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_dev_bi_vm1_pip_name'))]"
}
}
}],
"backendAddressPools": [{
"name": "devSnDblb-backend",
"etag": "W/\"a76fdd2a-96d9-4f76-9fa5-87699235647f\"",
"properties": {
"provisioningState": "Succeeded"
}
}],
"loadBalancingRules": [],
"probes": [],
"inboundNatRules": [{
"name": "dev-bi-vm1-nat-rdp",
"etag": "W/\"a76fdd2a-96d9-4f76-9fa5-87699235647f\"",
"properties": {
"provisioningState": "Succeeded",
"frontendIPConfiguration": {
"id": "[variables('frontEndIpConfigId')]"
},
"frontendPort": 3389,
"backendPort": 3389,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"protocol": "Tcp"
}
}],
"outboundNatRules": [],
"inboundNatPools": []
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_dev_bi_vm1_pip_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Network/networkInterfaces/dev-bi-vm1-nic1'.",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('networkInterfaces_dev_bi_vm1_nic1_name')]",
"apiVersion": "2017-06-01",
"location": "australiaeast",
"scale": null,
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "e12c648b-fa3c-4f90-92ab-b3901f729f76",
"ipConfigurations": [{
"name": "ipconfig1",
"etag": "W/\"d6de2fab-54c4-4d48-9e40-803eb64995c4\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "10.202.14.100",
"privateIPAllocationMethod": "Static",
"subnet": {
"id": "[variables('subnetResourceId')]"
},
"primary": true,
"privateIPAddressVersion": "IPv4",
"loadBalancerBackendAddressPools": [{
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_devSnDb_bi_lb_name')), '/backendAddressPools/devSnDblb-backend')]"
}],
"loadBalancerInboundNatRules": [{
"id": "[concat(resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_devSnDb_bi_lb_name')), '/inboundNatRules/dev-bi-vm1-nat-rdp')]"
}]
}
}],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": [],
"internalDomainNameSuffix": "vekaobcyzqfevo1ktytdiaasbe.px.internal.cloudapp.net"
},
"macAddress": "00-0D-3A-D1-57-35",
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"primary": true,
"virtualMachine": {
"id": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachines_dev_bi_vm1_name'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancers_devSnDb_bi_lb_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Network/publicIPAddresses/dev-bi-vm1-pip'.",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddresses_dev_bi_vm1_pip_name')]",
"apiVersion": "2017-06-01",
"location": "australiaeast",
"scale": null,
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "f3d81651-8042-40b0-8db3-3cff712aa800",
"ipAddress": "52.237.209.77",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4
},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Storage/storageAccounts/devbivm1st0'.",
"type": "Microsoft.Storage/storageAccounts",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "Storage",
"name": "[parameters('storageAccounts_devbivm1st0_name')]",
"apiVersion": "2016-01-01",
"location": "australiaeast",
"tags": {},
"scale": null,
"properties": {},
"dependsOn": []
},
{
"comments": "Generalized from resource: '/subscriptions/13f3d560-8319-4b5b-b762-ca62e0a4a1c7/resourceGroups/dev-bi-rg/providers/Microsoft.Compute/virtualMachines/dev-bi-vm1/extensions/BGInfo'.",
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[parameters('extensions_BGInfo_name')]",
"apiVersion": "2016-04-30-preview",
"location": "australiaeast",
"scale": null,
"properties": {
"publisher": "Microsoft.Compute",
"type": "BGInfo",
"typeHandlerVersion": "2.1",
"autoUpgradeMinorVersion": true
},
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachines_dev_bi_vm1_name'))]"
]
}
]
}
答案 0 :(得分:5)
该错误通常来自对模板中未定义的资源的依赖 - IOW其中一个“dependsOn”数组包含该resourceId。对于在同一模板中定义的资源,dependsOn仅 。
那就是说,我没有看到你粘贴的json,就像Gleb提到的那样,你的样本也适合我。
答案 1 :(得分:0)
为了执行模板,您需要确保子网" devSnDb"已经创建了。 访问https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-create-vnet-arm-ps以查找如何使用powershell创建子网,或者您可以直接从界面创建子网。 您还必须定位正确的订阅。