【问题标题】:Azure vnet cross subscription peeringAzure vnet 跨订阅对等互连
【发布时间】:2020-07-15 00:29:10
【问题描述】:

我正在尝试在新订阅中创建分支 vnet,并尝试通过 ARM 模板与另一个订阅中现有的中心 vnet 对等。做这个的最好方式是什么?您如何引用 Hub vnet?

这就是我引用集线器 vnet 的方式,但没有运气:

{
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2017-05-10",
      "name": "nestedTemplate",
      "resourceGroup": "[parameters('secondResourceGroup')]",
      "subscriptionId": "[parameters('secondSubscriptionID')]",
      "properties": {
      "mode": "Incremental",
      "template": {
          "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {},
          "variables": {},
          "resources": [
             "type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",
                    "apiVersion": "2019-11-01",
                    "properties": {
                                "allowVirtualNetworkAccess": true,
                                "allowForwardedTraffic": true,
                                "allowGatewayTransit": true,
                                "useRemoteGateways": false,
                                "remoteVirtualNetwork": "r_name",
                                "remoteAddressSpace": {
                                "addressPrefixes": "CIDR_spcae"
                                }
          ]
      },

【问题讨论】:

    标签: azure arm-template azure-template vnet


    【解决方案1】:

    您可以在 remoteVirtualNetwork 参数及其 ID 中引用不同订阅中的中心 VNet。

    Here 是一个示例,将<subscription ID> 替换为另一个订阅 ID。

    {
         "$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": "myVnetA/myVnetAToMyVnetB",
             "location": "[resourceGroup().location]",
             "properties": {
             "allowVirtualNetworkAccess": true,
             "allowForwardedTraffic": false,
             "allowGatewayTransit": false,
             "useRemoteGateways": false,
                 "remoteVirtualNetwork": {
                 "id": "/subscriptions/<subscription ID>/resourceGroups/PeeringTest/providers/Microsoft.Network/virtualNetworks/myVnetB"
                 }
             }
             }
         ]
    }
    

    您还可以从这个博客获得更多详细信息:Using ARM templates to create Azure Vnets, part 2: peering

    【讨论】:

    • 感谢南希的回复!我收到以下错误。部署模板验证失败:'The template resource'test-peering--spoke' for type'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Common.Entities.TemplateGenericProperty`1[System.String]' at line “1”和“545”列的段长度不正确。嵌套资源类型必须具有与其资源名称相同的段数。根资源类型的段长度必须比其资源名称大一。请参阅aka.ms/arm-template/#resources 了解使用详情。'。 (代码:无效模板
    • 你能展示你的完整模板吗?或者检查分区为错误显示A root resource type must have segment length one greater than its resource name.
    【解决方案2】:

    我想出了这个。问题是参数引用错误。

    【讨论】:

      猜你喜欢
      • 2018-11-14
      • 2019-02-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-26
      • 1970-01-01
      • 2017-02-02
      • 1970-01-01
      • 2017-06-23
      相关资源
      最近更新 更多