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

As Technology Architect, Ajeet has over 12+ years of industry experience delivering enterprise solutions on the Microsoft Platform. Ajeet is passionate, certified technologist, blogger and community contributor. His specialisms are Azure IaaS/PaaS, Automation, DevOps, Agile based development processes supporting distributed teams (on shore & off shore), designing and implementing the appropriate infrastructure and platform solutions to meet the functional, operational, and deployment requirements throughout the solution life-cycle. Ajeet is member of various technical communities and discussion groups. He also conducted many boot camps on Azure and DevOps.