How do I create an Azure VNET with an address space 10.10.0.0/16 and 4 subnets 10.10.0.0/24 in Azure Portal, Powershell, azurecli, Azure Cloudshell?

You can create an Azure Virtual Network (VNet) with a specific address space and multiple subnets using different methods, including the Azure portal, PowerShell, Azure CLI, and Cloud Shell. Here’s how you can create an Azure VNet with an address space of 10.10.0.0/16 and four subnets with a prefix of 10.10.0.0/24 using each of these methods:

Using Azure Portal:

Log in to the Azure portal.
Navigate to the Virtual Networks page.
Click "Add" to create a new VNet.

Enter a name and select a region for the VNet.
Set the address space to "10.10.0.0/16."
Under "Subnets," click "Add" to create the first subnet.

Enter a name and prefix of "10.10.0.0/24" for the first subnet.
Repeat step 6-7 for the remaining three subnets.
Click "Review + create" to review the settings.
Click "Create" to create the VNet and subnets.

Using PowerShell:

Open PowerShell and connect to your Azure account using the Connect-AzAccount cmdlet.
Create a new VNet using the New-AzVirtualNetwork cmdlet. Here's an example:

New-AzVirtualNetwork -Name “myVNet” -ResourceGroupName “myResourceGroup” -Location “EastUS” -AddressPrefix “10.10.0.0/16” -Subnet (
New-AzVirtualNetworkSubnetConfig -Name “subnet1” -AddressPrefix “10.10.0.0/24”
),(
New-AzVirtualNetworkSubnetConfig -Name “subnet2” -AddressPrefix “10.10.1.0/24”
),(
New-AzVirtualNetworkSubnetConfig -Name “subnet3” -AddressPrefix “10.10.2.0/24”
),(
New-AzVirtualNetworkSubnetConfig -Name “subnet4” -AddressPrefix “10.10.3.0/24”
)

Replace the values for Name, ResourceGroupName, Location, and AddressPrefix with the appropriate values for your VNet.
Press Enter to create the VNet and subnets.

Using Azure CLI:

Open Azure CLI and connect to your Azure account using the az login command.
Create a new VNet using the az network vnet create command. Here's an example:

az network vnet create –name myVNet –resource-group myResourceGroup –location eastus –address-prefixes 10.10.0.0/16 –subnet-name subnet1 –subnet-prefix 10.10.0.0/24 –subnet-name subnet2 –subnet-prefix 10.10.1.0/24 –subnet-name subnet3 –subnet-prefix 10.10.2.0/24 –subnet-name subnet4 –subnet-prefix 10.10.3.0/24

Replace the values for name, resource-group, location, address-prefixes, subnet-name, and subnet-prefix with the appropriate values for your VNet.
Press Enter to create the VNet and subnets.

To create an Azure VNet with an address space of 10.10.0.0/16 and four subnets with a prefix of 10.10.0.0/24 in Cloud Shell, follow these steps:

Open the Azure portal and click on the Cloud Shell icon located in the top right-hand corner of the screen. Alternatively, you can go directly to https://shell.azure.com/.

If prompted, select Bash as your shell environment.

Select the subscription you want to use for the VNet creation with the following command:

az account set –subscription

Create a new resource group in the same region where you want to create your VNet. Use the following command:

az group create –name myResourceGroup –location eastus

Replace “myResourceGroup” with the desired name for your resource group, and “eastus” with the desired region.

Create the VNet with the following command:

az network vnet create –name myVNet –resource-group myResourceGroup –address-prefixes 10.10.0.0/16 –subnet-name subnet1 –subnet-prefix 10.10.0.0/24 –subnet-name subnet2 –subnet-prefix 10.10.1.0/24 –subnet-name subnet3 –subnet-prefix 10.10.2.0/24 –subnet-name subnet4 –subnet-prefix 10.10.3.0/24

Replace “myVNet” with the desired name for your VNet.

Wait for the command to complete. Once it's finished, you should see the output with the details of the VNet that was just created.

Your Azure VNet with an address space of 10.10.0.0/16 and four subnets with a prefix of 10.10.0.0/24 should now be created and ready to use.

Author: tonyhughes