我正在尝试将新 VM 部署到新资源组中。我用于 VM 的 NIC 将属于新资源组,并将与来自另一个资源组中的 VNet 的子网相关联。(这目前在 Azure 中运行,我已经导出了一个模板,并且正在将其修复为工作状态以供将来重新部署)
这是我在尝试部署时收到的错误的副本: 错误截图
部署模板验证失败:模板中未定义资源“Microsoft.Network/virtualNetworks/prod-vnet/subnets/devSnDb”。请参阅https://aka.ms/arm-template了解使用详情。(代码:无效模板)
这是我正在处理的 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'))]"
]
}
]
}