Creating a VNet with a subnet

To get started, we will need a VNet with a subnet created. You need a subnet because NSGs are applied on the subnet level. To create a VNet with a subnet, you can use the following Azure CLI or PowerShell commands.

You can use the following commands in the CLI (see the Creating and configuring VNet-to-VNet connection section for reference):

$ az network vnet create -g myResourceGroup -n vnetName
$ az network vnet subnet create -g myResourceGroup --vnet-name vnetName -n subnetName --address-prefixes 10.0.0.0/16

Alternatively, you can use the following commands in PowerShell. They use the same parameters as the Azure CLI command—the only difference is the syntax:

$vnet = New-AzVirtualNetwork -AddressPrefix 10.0.0.0/16 -Location location -Name vnetName -ResourceGroupName myResourceGroup
Add-AzVirtualNetworkSubnetConfig -AddressPrefix 10.0.0.0/16 -Name subnetname-VirtualNetwork $vnet
Remember that you are not allowed to create a network security group if a subnet is a gateway subnet.

Once both the VNet and subnet are created, we are ready to create an NSG for them. 

Related Articles

How to add swap space on Ubuntu 21.04 Operating System

How to add swap space on Ubuntu 21.04 Operating System

The swap space is a unique space on the disk that is used by the system when Physical RAM is full. When a Linux machine runout the RAM it use swap space to move inactive pages from RAM. Swap space can be created into Linux system in two ways, one we can create a...

read more

Lorem ipsum dolor sit amet consectetur

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

4 + 13 =