使用ARM模板创建多个VNG连接时出现问题 [英] Issue in creating multiple VNG connections using ARM template

查看:65
本文介绍了使用ARM模板创建多个VNG连接时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 


我需要在不同的订阅中创建从一个虚拟网络网关到另一个(VNG)的多个连接


我正在尝试使用arm模板来完成这项工作,因为我知道其他VGW的ID


我的问题是   RemoteVirtualGatewayID。我无法将其定义为数组,因为资源下的ID
只接受整数。


知道怎么做这个工作吗?


注意 - 我删除了实际ID和提供虚拟价值





 {
" $ schema":" https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" ,
" contentVersion":" 1.0.0.0",
" parameters" ;: {
" RemoteVirtualGatewayID":{
" type":" int" ;,
" defaultValue":[
" VGWID1",
" VGWI2"
],
" metadata":{
" description":""
}
},
" ConnectionName" ;: {
" type":" array",
" defaultValue":[
" ; con1",
" con2"
],
" metadata":{
" description":" Azure Subnet的任意名称"
}
},
" sharedKey" ;: {
" type":" SecureString",
" metadata":{
" ;描述":" IPSec隧道的共享密钥(PSK)"
}
}
},
" variables" ;: {
" ESMVirtualGatewayID":" GatewayID",
" ESMVGWlocation":" ;北欧"

},
" resources" ;: [

{
" type":" Microsoft.Network/connections",
" name":" [parameters('ConnectionName')]",
" apiVersion":" 2015-06-15",
" location":" [variables ('ESMVGWlocation')]",
" copy":{
" count":" [parameters('ConnectionName')]",
" name": " connectionNameloop"
},

" copy" ;: {
" name":" connectionLoop",
" count":" [parameters('RemoteVirtualGatewayID ")]"
},
" properties":{
" virtualNetworkGateway1":{
" id":" [variables('ESMVirtualGatewayID')]"
},
" virtualNetworkGateway2":{
" id":" [parameters('RemoteVirtualGatewayID')]"
},
" connectionType":" Vnet2Vnet",
" routingWeight":10,
" sharedKey":" [parameters('sharedKey')] "
}

}


]
}

解决方案

您可以使用以下代码段获取ID的整数值。

" virtualNetworkGateway1":{
" id":" [resourceId('Microsoft.Network/virtualNetworkGateways',parameters('RemoteVirtualGatewayID'))]"
}

要从复制块中的数组中获取计数值,请尝试使用以下代码段。


< pre class ="prettyprint">" count":" [length(parameters('RemoteVirtualGatewayID'))]"


以下是一些参考文章,可帮助您创建多个VNG连接


 


  1. VNET
    到VNET连接模板
  2. < a href ="https://docs.microsoft.com/en-us/azure/azure-res source-manager / resource-group-create-multiple">在ARM中部署
    多个资源或属性实例
  3. Virtual
    网络网关模板格式


Hi 

I've a requirement to create multiple connections from one Virtual network gateway to another ( VNG ) in a different subscription

I'm trying to get this work using arm template as I know the ID of the other VGW

The issue is I've is with the  RemoteVirtualGatewayID. I can't define it as an array as the ID under resources accepts only integer.

Any idea how to get this work ?

Note - I've removed the actual ID and provided dummy value


{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
      "parameters": {
        "RemoteVirtualGatewayID": {
            "type": "int",
            "defaultValue": [ 
                "VGWID1", 
                "VGWI2"       
              ],
            "metadata": {
              "description": ""
            }    
        },
        "ConnectionName": {
            "type": "array",
            "defaultValue": [ 
                "con1", 
                "con2"         
              ],
            "metadata": {
              "description": "Arbitrary name for the Azure Subnet"
            }
        },
        "sharedKey": {
            "type": "SecureString",
            "metadata": {
                "description": "Shared key (PSK) for IPSec tunnel"
            }
        }
    },
    "variables": {
        "ESMVirtualGatewayID": "GatewayID",
        "ESMVGWlocation": "North Europe"
        
    },
    "resources": [
       
        {
            "type": "Microsoft.Network/connections",
            "name": "[parameters('ConnectionName')]",
            "apiVersion": "2015-06-15",
            "location": "[variables('ESMVGWlocation')]",
            "copy":{
                "count": "[parameters('ConnectionName')]",
                "name": "connectionNameloop"
              },

            "copy": {
                "name": "connectionLoop",
                "count": "[parameters('RemoteVirtualGatewayID')]"
              },
            "properties": {
                "virtualNetworkGateway1": {
                    "id": "[variables('ESMVirtualGatewayID')]"
                },
                "virtualNetworkGateway2": {
                    "id": "[parameters('RemoteVirtualGatewayID')]"
                },
                "connectionType": "Vnet2Vnet",
                "routingWeight": 10,
                "sharedKey": "[parameters('sharedKey')]"
            }
            
        }
      
       
    ]
}

解决方案

You can get the integer value of ID, using below snippet.

   "virtualNetworkGateway1": {	
	"id": "[resourceId('Microsoft.Network/virtualNetworkGateways',parameters('RemoteVirtualGatewayID'))]"
	}

To get the count value from an array in copy block , try using the below snippet.

"count": "[length(parameters('RemoteVirtualGatewayID'))]" 

Below are some reference articles , that will help you to create multiple VNG connections

 

  1. VNET to VNET Connection Template
  2. Deploy more than one instance of a resource or property in ARM
  3. Virtual Network Gateway Template Format


这篇关于使用ARM模板创建多个VNG连接时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆