如何使用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
addressPrefixesarray underaddressSpaceincludes exactly the two CIDR blocks you specified. - I added a sample
DefaultSubnetto demonstrate how to carve out parts of your address space—feel free to remove it or add more subnets for your workloads. - Parameters like
virtualNetworkNameandlocationhave 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
相关产品推荐
相关产品推荐

