
In this Azure tutorial, we will discuss how to create VNet in Azure. Along with that, we will also discuss a few other topics below
- What is vnet in Azure?
- How to create a virtual network Azure Portal
- Create VNet in Azure using PowerShell
- How to create a virtual network in Azure using PowerShell
- Creating VNet using Azure CLI
Table of Contents
How To Create VNet In Azure
Before discussing how to create VNet in Azure, we should have a little bit of an idea of what is VNet in Azure then we will discuss the Prerequisites needed to create VNet in Azure and then we will discuss the steps to create VNet in Azure.
What is VNet in Azure
Azure Virtual Network (VNet) is your private network in Azure. It represents your Private network on the cloud. Your Azure virtual machines (VMs) can communicate securely with each other using the virtual network created by you.
For higher security, you have the provision to divide a VNet into multiple subnets.
This is a small introduction to the virtual network in Azure. Now, Assuming you have a bit idea of what is VNet in Azure, let’s discuss the Prerequisites needed to create VNet in Azure.
Prerequisites
You must have an Azure account or Azure Subscription. If you don’t have it till now, Create an Azure Free Account now.
How to create a virtual network Azure Portal
Well, it’s quite easy to create VNet in Azure using Azure Portal. Follow the below steps
- Log in to the Azure Portal (https://portal.azure.com/).
- Search for Virtual Network and click on the search result Virtual Networks.

Or, for the same steps, you can click on the + Create a resource option from the top left corner in the Azure Portal.

Search for Virtual Network and click on the search result Virtual Network.

3. Click on the Create button on the Virtual Network window.

4. On the Create virtual network window, select the Basics tab and then provide the below details
- Subscription: Select the subscription that you want to use here.
- Resource group: Select an existing resource group or you can create a new resource group using the Create new link.
- Name: Provide a name for the virtual network.
- Region: Select the Region.
Click on the Next: IP Addresses > button to navigate to the IP Addresses window.

5. Now, it will validate all the data entered by you and show you the Validation passed. Finally, click on the Create button to create the Virtual network.

6. Now, it will show you “Your deployment is complete”. Click on the Go to Resource button to navigate to the virtual network.

Create VNet in Azure using PowerShell
Well, Let’s discuss here how to create a virtual network in Azure using PowerShell. Before discussing the actual functionality, we should know the prerequisites needed here to create a virtual network in Azure using PowerShell.
Prerequisites
Below are the prerequisites needed to create VNet in Azure using PowerShell.
- You must have an Azure account or Azure Subscription. If you don’t have it till now, Create an Azure Free Account now.
- You must install the latest version of Azure Power Shell on your machine. If you have not yet installed it, Install Azure PowerShell now.
The first step is we need to create a resource group. The resource group will be responsible to host the virtual network.
Creating a resource group using PowerShell
Execute the below Azure Powershell cmdlet to create a resource group in Azure.
$rsgrp = @{
Name = 'Demo980'
Location = 'EastUS'
}
New-AzResourceGroup @rsgrp
Once you will execute the above Azure PowerShell cmdlet, you will get the output like below
ResourceGroupName : Demo980
Location : eastus
ProvisioningState : Succeeded
Tags :
ResourceId : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72f6gbd1/resourceGroups
/Demo980
You can check it out below

Here, “Demo980” is the name of our resource group, and “EastUS” is the name of the location.
Now is the time to create the Virtual Network as the next step.
Creating Virtual Network PowerShell
Execute the below Azure PowerShell script. Where TSInfoVNet1 is the name of the virtual network. Demo980 is the resource group name that we have created above
$myvnetw = @{
Name = 'TSInfoVNet1'
ResourceGroupName = 'Demo980'
Location = 'EastUS'
AddressPrefix = '10.0.0.0/16'
}
$virtualNetwork = New-AzVirtualNetwork @myvnetw
Once we will run the above script, TSInfoVNet1 virtual network will be created for us.
Now just to cross-check, I have logged in to Azure Portal and could see the virtual network got created successfully.

Now the next step is to add a subnet.
Adding a subnet
You can use the below Azure PowerShell script to add a subnet.
$subnet = @{
Name = 'default'
VirtualNetwork = $virtualNetwork
AddressPrefix = '10.0.0.0/24'
}
$subnetConfig = Add-AzVirtualNetworkSubnetConfig @subnet
Now we have added a subnet, Not the time to associate the subnet to the virtual network.
Associating the Subnet to the Virtual Network
Use the below Azure PowerShell cmdlet to associate the subnet to the Virtual Network.
$virtualNetwork | Set-AzVirtualNetwork
Once you will execute the above PowerShell cmdlet, you will get the output as below
Name : TSInfoVNet1
ResourceGroupName : Demo980
Location : eastus
Id : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceG
roups/Demo980/providers/Microsoft.Network/virtualNetworks/TSI
nfoVNet1
Etag : W/"115d206e-1651-444c-b382-774b94adef37"
ResourceGuid : fb1b0c6a-646a-441c-a956-a256027d2045
ProvisioningState : Succeeded
Tags :
AddressSpace : {
"AddressPrefixes": [
"10.0.0.0/16"
]
}
DhcpOptions : {
"DnsServers": []
}
Subnets : [
{
"Delegations": [],
"Name": "default",
"Etag": "W/\"115d206e-1651-444c-b382-774b94adef37\"",
"Id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd
1/resourceGroups/Demo980/providers/Microsoft.Network/virtualN
etworks/TSInfoVNet1/subnets/default",
"AddressPrefix": [
"10.0.0.0/24"
],
"IpConfigurations": [],
"ServiceAssociationLinks": [],
"ResourceNavigationLinks": [],
"ServiceEndpoints": [],
"ServiceEndpointPolicies": [],
"PrivateEndpoints": [],
"ProvisioningState": "Succeeded",
"PrivateEndpointNetworkPolicies": "Enabled",
"PrivateLinkServiceNetworkPolicies": "Enabled",
"IpAllocations": []
}
]
VirtualNetworkPeerings : []
EnableDdosProtection : false
DdosProtectionPlan : null
Creating VNet In Azure using Azure CLI
Well, we have already discussed above, how to create VNet using Azure Portal and How to create VNet using PowerShell. Now, let’s discuss how to create VNet using Azure CLI. But before that, we should know the Prerequisites needed here.
Prerequisites
Below are the Prerequisites needed for creating the virtual network using Azure CLI.
- You must have an Azure account or Azure Subscription. If you don’t have it till now, Create an Azure Free Account now.
- You need to install the latest version of Azure CLI. If you have not yet installed Azure CLI on your machine, Install Azure CLI now.
- Don’t forget to install Azure CLI extensions if you are using for the first time.
The first thing is you need to create the resource group using Azure CLI.
Creating the Resource Group using Azure CLI
You can use the below cmdlet to create a resource group using Azure CLI. That will create the resource group named Demo906 and the location is east us.
az group create --name Demo906 --location eastus
Once you will execute the above cmdlet, you will get the output below
bijay@Azure:~$ az group create --name Demo906 --location eastus
{
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo906",
"location": "eastus",
"managedBy": null,
"name": "Demo906",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
Creating VNet using Azure CLI
Now, we need to create the virtual network using Azure CLI. Execute the below script to create the virtual network using Azure CLI.
az network vnet create
--name TSInfoVNet3 --resource-group Demo906 --subnet-name default
Once you will execute the above script, it will create the virtual network named TSInfoVNet3 with the resource group name Demo906 and subnet name as default.
You will get the output below
{
"newVNet": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"bgpCommunities": null,
"ddosProtectionPlan": null,
"dhcpOptions": {
"dnsServers": []
},
"enableDdosProtection": false,
"enableVmProtection": null,
"etag": "W/\"f1b27aa3-4ff6-484d-b109-a64306bdff6b\"",
"extendedLocation": null,
"flowTimeoutInMinutes": null,
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo906/providers/Microsoft.Network/virtualNetworks/TSInfoVNet3",
"ipAllocations": null,
"location": "eastus",
"name": "TSInfoVNet3",
"provisioningState": "Succeeded",
"resourceGroup": "Demo906",
"resourceGuid": "39b01a17-124b-4b6e-a0ab-f2a45ac8ff2b",
"subnets": [
{
"addressPrefix": "10.0.0.0/24",
"addressPrefixes": null,
"applicationGatewayIpConfigurations": null,
"delegations": [],
"etag": "W/\"f1b27aa3-4ff6-484d-b109-a64306bdff6b\"",
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/Demo906/providers/Microsoft.Network/virtualNetworks/TSInfoVNet3/subnets/default",
"ipAllocations": null,
"ipConfigurationProfiles": null,
"ipConfigurations": null,
"name": "default",
"natGateway": null,
"networkSecurityGroup": null,
"privateEndpointNetworkPolicies": "Enabled",
"privateEndpoints": null,
"privateLinkServiceNetworkPolicies": "Enabled",
"provisioningState": "Succeeded",
"purpose": null,
"resourceGroup": "Demo906",
"resourceNavigationLinks": null,
"routeTable": null,
"serviceAssociationLinks": null,
"serviceEndpointPolicies": null,
"serviceEndpoints": null,
"type": "Microsoft.Network/virtualNetworks/subnets"
}
],
"tags": {},
"type": "Microsoft.Network/virtualNetworks",
"virtualNetworkPeerings": []
}
}
This is how to create VNet using Azure CLI.
FAQs
How to delete a virtual network in Azure
Now if you don’t want the VNet anymore and you are actually not using that then in that case, it’s better to delete it.
Before deleting the Virtual Network in Azure, An important point to note down here is, If any resources are connected to that virtual network, you need to delete the resources first before deleting the Virtual Network.
So basically, delete the connected resources first and then delete the virtual network.
Follow the below steps to delete the Virtual Network using the Azure Portal.
- Log in to the Azure Portal (https://portal.azure.com/) and search for Virtual networks.
- Click on the Search result Virtual networks.

3. Now You can see the list of Virtual Networks you have created. Click the one that you want to delete.
4. On the Virtual Network page, click on the Delete button to delete the VNet.

5. Finally, click on the Yes button to confirm the deletion.
What is Azure subnet
- A subnet is an important concept that you must know while working with virtual networks.
- The process of dividing a network into small networks is known as a subnet.
- An Azure subnet is nothing but a range of IP addresses in the Azure virtual network.
- It’s better to divide a virtual network into multiple subnets in terms of security.
- It’s all about dividing the IP range of a Virtual network into multiple subnet IP ranges.
- The Azure resources that are present inside the Azure subnet can communicate with each other and also with the help of Network Security Groups (NSGs), the Azure resources present across the Azure subnets inside the same Azure virtual network can communicate with each other.
- The role of the Network Security Groups (NSGs) is quite crucial as it helps to control the traffic from or to the subnets.
You may also like following the below articles
Wrapping Up
Well, in this article, we have discussed how to create VNet in Azure, and along with that we have also discussed the below topics
- What is vnet in Azure
- How to create a virtual network Azure Portal
- Create VNet in Azure using PowerShell
- How to create a virtual network in Azure using PowerShell
- Creating VNet using Azure CLI
Hope, you have enjoyed this article !!!