You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用JSON模板为Azure RM虚拟网络添加多个地址空间

Azure VNet JSON Template with Multiple Address Prefixes

Got it, here's a ready-to-use ARM (Azure Resource Manager) JSON template that provisions a virtual network with your specified vnetAddressPrefixes: 192.168.0.0/24 and 10.0.0.0/24. I've added inline comments to clarify each section, making it easy to adjust for your specific needs:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    // Customize these parameters or add more as needed
    "virtualNetworkName": {
      "type": "string",
      "defaultValue": "MyCustomVNet",
      "metadata": {
        "description": "Name of the virtual network to create"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for the virtual network"
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2023-05-01",
      "name": "[parameters('virtualNetworkName')]",
      "location": "[parameters('location')]",
      "properties": {
        "addressSpace": {
          // Your requested address prefixes live here
          "addressPrefixes": [
            "192.168.0.0/24",
            "10.0.0.0/24"
          ]
        },
        // Optional: Add subnets here if you need to split the address space
        "subnets": [
          {
            "name": "DefaultSubnet",
            "properties": {
              "addressPrefix": "192.168.0.0/26"
            }
          }
        ]
      }
    }
  ],
  "outputs": {
    "virtualNetworkId": {
      "type": "string",
      "value": "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]"
    },
    "virtualNetworkAddressPrefixes": {
      "type": "array",
      "value": "[reference(parameters('virtualNetworkName')).addressSpace.addressPrefixes]"
    }
  }
}

Key Notes:

  • The addressPrefixes array under addressSpace includes exactly the two CIDR blocks you specified.
  • I added a sample DefaultSubnet to demonstrate how to carve out parts of your address space—feel free to remove it or add more subnets for your workloads.
  • Parameters like virtualNetworkName and location have sensible defaults but can be easily overridden during deployment.
  • The outputs section returns the VNet's ID and its address prefixes, which comes in handy if you're linking this template to other resources (like VMs or private endpoints).

If you need to tweak the API version, add tags, or include extra VNet features (like custom DNS servers or service endpoints), just modify the relevant sections of the template.


内容的提问来源于stack exchange,提问作者Sam Hodgkinson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:15:36