Virtual Network

The Azure Virtual Network service enables you to securely connect Azure resources to each other with virtual networks (VNets). A VNet is a representation of your own network in the cloud. A VNet is a logical isolation of the Azure cloud dedicated to your subscription. You can also connect VNets to your on-premises network.

Subnet

Understand the CIDR notation CIDR (Classless Inter-Domain Routing, sometimes called supernetting) is a way to allow more flexible allocation of Internet Protocol (IP) addresses than was possible with the original system of IP address classes. As a result, the number of available Internet addresses was greatly increased, which along with widespread use of network address translation (NAT), has significantly extended the useful life of IPv4.

http://whatismyipaddress.com/cidr

CIDR Tool

PowerShell

        New-AzureRmResourceGroup -Name TestRG -Location centralus
        
        New-AzureRmVirtualNetwork -ResourceGroupName TestRG -Name TestVNet `
        -AddressPrefix 192.168.0.0/16 -Location centralus
        
        $vnet = Get-AzureRmVirtualNetwork -ResourceGroupName TestRG -Name TestVNet
        
        Add-AzureRmVirtualNetworkSubnetConfig -Name FrontEnd `
        -VirtualNetwork $vnet -AddressPrefix 192.168.1.0/24
        
        Add-AzureRmVirtualNetworkSubnetConfig -Name BackEnd `
        -VirtualNetwork $vnet -AddressPrefix 192.168.2.0/24
        
        Set-AzureRmVirtualNetwork -VirtualNetwork $vnet
        

ARM Template

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "string"
        },
        "location": {
            "type": "string"
        },
        "addressPrefix": {
            "type": "string",
            "defaultValue": "10.0.0.0/16"
        },
        "subnetName": {
            "type": "string",
            "defaultValue": "subnet-1"
        },
        "subnetAddressPrefix": {
            "type": "string",
            "defaultValue": "10.0.0.0/24"
        }
    },
    "resources": [
        {
            "apiVersion": "2016-06-01",
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[parameters('name')]",
            "location": "[parameters('location')]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[parameters('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[parameters('subnetName')]",
                        "properties": {
                            "addressPrefix": "[parameters'subnetAddressPrefix')]"
                        }
                    }
                ]
            }
        }
    ]
}

Reusable template

See complete code - vnet resource FAQ See Azure documentation


Please do let me know your thoughts/ suggestions/ question in disqus section.


Related Posts

About Ajeet Chouksey

With a robust background spanning more than 18 years, I am an adept Azure and Azure DevOps architect and engineer, dedicated to crafting Azure-centric solutions that prioritize customer requirements and agile methodologies. My expertise encompasses steering extensive cloud migration initiatives and advocating for Azure best practices, all aimed at streamlining costs and steering multinational teams towards success. Fueled by a passion for technological innovation, I am committed to perpetual learning, constantly advancing my proficiency in Azure, AI, MLOps, and Product Management to stay at the forefront of the industry..