【问题标题】:Azure ARM Templates: How to use template to create a vnet and peer it to an existing vnet?Azure ARM 模板:如何使用模板创建 vnet 并将其与现有 vnet 对等?
【发布时间】:2019-01-15 17:27:46
【问题描述】:

部署 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}"}]}

【问题讨论】:

    标签: azure azure-resource-manager azure-template


    【解决方案1】:

    您需要使用将更新另一个资源组中的 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
        }
    }
    

    如果输入正确,您将需要上述 2 个

    【讨论】:

    • 是的,这正是我正在做的。资源标签中的三个资源:vNet、vNet to RemoteVNET Peering和RemoteVNET to vNet Peering。但是Azure部署一直报错RemoteVNET找不到,即使它在同一个资源组中。
    • 我检查了很多次。 resourceId 正确。
    • 好吧,不看模板和完整的错误文本什么都做不了
    • 我已经编辑了我的问题和带有错误消息的模板。
    • 是的,使用相同的技术
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 2019-06-03
    相关资源
    最近更新 更多