Bird
Raised Fist0
Azurecloud~5 mins

VNet creation and address space in Azure - Commands & Configuration

Choose your learning style10 modes available
Introduction
A Virtual Network (VNet) lets you create a private network in the cloud. It helps you control how your cloud resources communicate securely by defining address spaces and subnets.
When you want to isolate your cloud resources from the public internet.
When you need to connect multiple cloud services securely within the same network.
When you want to define IP address ranges for your cloud resources to avoid conflicts.
When you plan to connect your cloud network to your on-premises network.
When you want to control traffic flow between different parts of your cloud environment.
Config File - vnet-template.json
vnet-template.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2022-07-01",
      "name": "example-vnet",
      "location": "eastus",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "10.0.0.0/16"
          ]
        },
        "subnets": [
          {
            "name": "default",
            "properties": {
              "addressPrefix": "10.0.0.0/24"
            }
          }
        ]
      }
    }
  ]
}

This JSON file is an Azure Resource Manager (ARM) template that creates a Virtual Network named example-vnet in the eastus region.

The addressSpace defines the IP range 10.0.0.0/16 for the whole network.

The subnets section creates one subnet named default with the IP range 10.0.0.0/24 inside the VNet.

Commands
This command creates a resource group named example-resource-group in the eastus region. Resource groups hold related cloud resources together.
Terminal
az group create --name example-resource-group --location eastus
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-resource-group", "location": "eastus", "managedBy": null, "name": "example-resource-group", "properties": { "provisioningState": "Succeeded" }, "tags": {}, "type": "Microsoft.Resources/resourceGroups" }
→
--name - Specifies the name of the resource group
→
--location - Specifies the Azure region for the resource group
This command deploys the ARM template file vnet-template.json to create the Virtual Network inside the example-resource-group.
Terminal
az deployment group create --resource-group example-resource-group --template-file vnet-template.json
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-resource-group/providers/Microsoft.Resources/deployments/deploymentName", "name": "deploymentName", "properties": { "provisioningState": "Succeeded", "outputs": {} } }
→
--resource-group - Specifies the resource group to deploy the template
→
--template-file - Specifies the ARM template file to use for deployment
This command shows details of the Virtual Network named example-vnet to verify it was created with the correct address space.
Terminal
az network vnet show --resource-group example-resource-group --name example-vnet
Expected OutputExpected
{ "addressSpace": { "addressPrefixes": [ "10.0.0.0/16" ] }, "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/example-vnet", "location": "eastus", "name": "example-vnet", "properties": { "subnets": [ { "addressPrefix": "10.0.0.0/24", "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/example-vnet/subnets/default", "name": "default" } ] }, "resourceGroup": "example-resource-group", "type": "Microsoft.Network/virtualNetworks" }
→
--resource-group - Specifies the resource group containing the VNet
→
--name - Specifies the name of the VNet to show
Key Concept

If you remember nothing else from this pattern, remember: defining the address space correctly when creating a VNet controls how your cloud resources communicate privately.

Common Mistakes
Using overlapping IP address ranges in multiple VNets or subnets
This causes IP conflicts and prevents proper communication between resources.
Plan and assign unique, non-overlapping IP address ranges for each VNet and subnet.
Not specifying the correct resource group when deploying the template
The deployment will fail or create resources in an unintended group, causing confusion.
Always use the correct resource group name with --resource-group flag during deployment.
Forgetting to verify the VNet creation after deployment
You might miss errors or misconfigurations that affect your network setup.
Run az network vnet show to confirm the VNet and its address space are correct.
Summary
Create a resource group to hold your cloud resources using az group create.
Deploy an ARM template defining the VNet and its address space with az deployment group create.
Verify the VNet creation and address space using az network vnet show.

Practice

(1/5)
1. What does the address space in an Azure Virtual Network (VNet) define?
easy
A. The physical location of the VNet data center
B. The number of virtual machines allowed in the VNet
C. The range of IP addresses available for resources inside the VNet
D. The security rules applied to the VNet

Solution

  1. Step 1: Understand the purpose of address space in VNet

    The address space specifies the IP address range that the VNet can use for its resources.
  2. Step 2: Differentiate from other VNet properties

    Physical location, VM count, and security rules are separate configurations unrelated to address space.
  3. Final Answer:

    The range of IP addresses available for resources inside the VNet -> Option C
  4. Quick Check:

    Address space = IP range [OK]
Hint: Address space means IP range inside the VNet [OK]
Common Mistakes:
  • Confusing address space with location
  • Thinking address space limits VM count
  • Mixing address space with security settings
2. Which Azure CLI command correctly creates a VNet named MyVNet with address space 10.0.0.0/16 in resource group MyGroup?
easy
A. az network vnet create --name MyVNet --resource-group MyGroup --address-prefixes 10.0.0.0/16
B. az network vnet create --vnet-name MyVNet --group MyGroup --address-space 10.0.0.0/16
C. az vnet create --name MyVNet --resource-group MyGroup --address 10.0.0.0/16
D. az network vnet new --name MyVNet --resource-group MyGroup --address-prefix 10.0.0.0/16

Solution

  1. Step 1: Identify correct Azure CLI syntax for VNet creation

    The correct command uses az network vnet create with parameters --name, --resource-group, and --address-prefixes.
  2. Step 2: Check each option for syntax correctness

    az network vnet create --name MyVNet --resource-group MyGroup --address-prefixes 10.0.0.0/16 matches the correct syntax. Other options use incorrect commands (like az vnet create or az network vnet new) or parameter names (like --vnet-name, --group, --address-space, --address, --address-prefix).
  3. Final Answer:

    az network vnet create --name MyVNet --resource-group MyGroup --address-prefixes 10.0.0.0/16 -> Option A
  4. Quick Check:

    Correct CLI syntax = az network vnet create --name MyVNet --resource-group MyGroup --address-prefixes 10.0.0.0/16 [OK]
Hint: Use --address-prefixes for IP range in az network vnet create [OK]
Common Mistakes:
  • Using wrong parameter names like --address-space
  • Using incorrect commands like az vnet create
  • Mixing resource group parameter names
3. Given the Azure CLI command:
az network vnet create --name TestVNet --resource-group TestGroup --address-prefixes 192.168.0.0/24

What is the size of the IP address range allocated to TestVNet?
medium
A. 1024 IP addresses
B. 65,536 IP addresses
C. 16 IP addresses
D. 256 IP addresses

Solution

  1. Step 1: Understand CIDR notation /24

    The /24 means the first 24 bits are fixed, leaving 8 bits for host addresses.
  2. Step 2: Calculate number of IP addresses

    2^8 = 256 IP addresses are available in the 192.168.0.0/24 range.
  3. Final Answer:

    256 IP addresses -> Option D
  4. Quick Check:

    /24 = 256 IPs [OK]
Hint: /24 means 256 IP addresses in the range [OK]
Common Mistakes:
  • Confusing /24 with /16 or /28
  • Miscounting IP addresses as 1024 or 65,536
  • Ignoring subnet mask meaning
4. You try to create a VNet with the command:
az network vnet create --name MyVNet --resource-group MyGroup --address-prefixes 10.0.0.0/16 10.0.0.0/24

But it fails. What is the most likely reason?
medium
A. The VNet name is already in use
B. You cannot specify overlapping address spaces in one VNet
C. The resource group name is invalid
D. The command requires a location parameter

Solution

  1. Step 1: Analyze the address prefixes given

    The prefixes 10.0.0.0/16 and 10.0.0.0/24 overlap because /24 is a subset of /16.
  2. Step 2: Understand Azure VNet address space rules

    Azure does not allow overlapping address spaces within the same VNet.
  3. Final Answer:

    You cannot specify overlapping address spaces in one VNet -> Option B
  4. Quick Check:

    Overlapping address spaces cause failure [OK]
Hint: Avoid overlapping IP ranges in one VNet [OK]
Common Mistakes:
  • Assuming location is mandatory for this error
  • Thinking resource group name causes this error
  • Believing VNet name conflict causes this error
5. You want to create a VNet with two non-overlapping address spaces: 10.1.0.0/16 and 10.2.0.0/16. Which command correctly creates this VNet named MultiVNet in resource group RG1?
hard
A. az network vnet create --name MultiVNet --resource-group RG1 --address-prefixes 10.1.0.0/16 10.2.0.0/16
B. az network vnet create --name MultiVNet --resource-group RG1 --address-prefix 10.1.0.0/16,10.2.0.0/16
C. az network vnet create --name MultiVNet --resource-group RG1 --address-prefixes 10.1.0.0/16,10.2.0.0/16
D. az network vnet create --name MultiVNet --resource-group RG1 --address-space 10.1.0.0/16 10.2.0.0/16

Solution

  1. Step 1: Check correct parameter for multiple address spaces

    The parameter --address-prefixes accepts multiple space-separated CIDR blocks.
  2. Step 2: Validate syntax for multiple prefixes

    az network vnet create --name MultiVNet --resource-group RG1 --address-prefixes 10.1.0.0/16 10.2.0.0/16 uses space-separated prefixes correctly. Using commas to separate prefixes, singular --address-prefix, or --address-space instead of --address-prefixes is invalid.
  3. Final Answer:

    az network vnet create --name MultiVNet --resource-group RG1 --address-prefixes 10.1.0.0/16 10.2.0.0/16 -> Option A
  4. Quick Check:

    Multiple prefixes = space-separated with --address-prefixes [OK]
Hint: Use --address-prefixes with spaces for multiple CIDRs [OK]
Common Mistakes:
  • Using commas instead of spaces between prefixes
  • Using --address-prefix instead of --address-prefixes
  • Using --address-space which is invalid
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard