繁体   English   中英

Azure ARM模板:如何使用模板创建vnet并将其对等到现有vnet?

[英]Azure ARM Templates: How to use template to create a vnet and peer it to an existing vnet?

部署VNET,并将新部署的VNET与其他资源组中的现有VNET对等的Azure ARM模板?

请在下面找到JSON模板:

{“ $ schema”:“ https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json# ”,“ contentVersion”:“ 1.0.0.0”,

"parameters": {},
"variables": {},
"resources": [
    {
        "apiVersion": "2016-03-30",
        "type": "Microsoft.Network/virtualNetworks",
        "name": "SpokevNet",
        "location": "[resourceGroup().location]",
        "comments": "This is the first vNet",
        "properties": {
            "addressSpace": {
                "addressPrefixes": [
                    "10.238.70.0/25"
                ]
            },
            "subnets": [
                {
                    "name": "SpokeSubNet",
                    "properties": {
                        "addressPrefix": "10.238.70.0/26"
                    }
                }
            ]
        }
    },
    {
        "apiVersion": "2017-05-10",
        "name": "nestedTemplate",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "PrdHUBRG",
        "properties": {
            "mode": "Incremental",
            "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {},
                "variables": {},
                "resources": [
                    {
                        "apiVersion": "2016-06-01",
                        "type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",
                        "name": "virtualNetworks/spoketoHubPeering",
                        "location": "[resourceGroup().location]",
                        "dependsOn": [
                            "[concat('Microsoft.Network/virtualNetworks/', PrdEUW1VN002)]",
                            "[concat('Microsoft.Network/virtualNetworks/', SpokevNet)]"
                        ],
                        "comments": "This is the peering from vNet 1 to vNet 2",
                        "properties": {
                            "allowVirtualNetworkAccess": "true",
                            "allowForwardedTraffic": "false",
                            "allowGatewayTransit": "false",
                            "useRemoteGateways": "false",
                            "remoteVirtualNetwork": {
                                "id": "/subscriptions/4adb8053-2339-4041-802d-d0b0f8fe3487/resourceGroups/PrdHUBRG/providers/Microsoft.Network/virtualNetworks/PrdEUW1VN002"
                            }
                        }
                    }
                ]
            },
            "parameters": {}
        }
    }


    } 


]

}

这是我不断得到的错误:

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"Conflict","message":"{\r\n \"status\": \"Failed\",\r\n \"error\": {\r\n \"code\": \"ResourceDeploymentFailure\",\r\n \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n \"details\": [\r\n {\r\n \"code\": \"DeploymentFailed\",\r\n \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.\",\r\n \"details\": [\r\n {\r\n \"code\": \"NotFound\",\r\n \"message\": \"{\\r\\n \\\"error\\\": {\\r\\n \\\"code\\\": \\\"ResourceNotFound\\\",\\r\\n \\\"message\\\": \\\"The Resource 'Microsoft.Network/virtualNetworks/virtualNetworks' under resource group 'PrdHUBRG' was not found.\\\"\\r\\n }\\r\\n}\"\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}"}]}

您需要使用跨资源组部署,该部署将更新另一个资源组中的vnet。 并且您需要配置您的vnet。 独立的对等资源看起来像这样:

{
    "apiVersion": "2017-04-01",
    "name": "name",
    "location": "location",
    "type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",
    "properties": {
        "remoteVirtualNetwork": {
            "id": "resourceId"
        },
        "allowVirtualNetworkAccess": true,
        "allowForwardedTraffic": false,
        "allowGatewayTransit": false,
        "useRemoteGateways": false
    }
}

您将需要上述两个中的正确输入

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM