Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Create a Azure vNet and Subnet Using PowerShell

August 12, 2022
in Blog, Microsoft Azure, Powershell
0
ADVERTISEMENT

Table of Contents

In this post, how to create a virtual network and subnet on Microsoft Azure using PowerShell.

Azure Virtual Networks (VNET)

Azure Virtual Networks (VNET) is important to any Azure security best practices. The VNET infrastructure can support any deployment topology, meet evolving application business needs, and offer scalability at the data center level. This also includes the ability to monitor, control, and optimize costs across all networks available in Azure.

The most common topologies that are supported by Azure Virtual Networks (VNETs) include having multiple cloud services in a single VNET, hosting virtual machines across different host servers, and distributing network traffic among data centers.

Virtual networks are the foremost component in Azure unified networking. They provide network isolation, traffic monitoring and control using both security groups and network security groups (NSG), as well as basic connectivity management, bandwidth throttling for data transfer between virtual machines (VMs), VM-to-VM connection configurations, endpoint services to create VPNs or ExpressRoute connections.

Connect to Microsoft Azure PowerShell

First, you need connect to Microsoft Azure PowerShell, there’re two ways to run PowerShell commands in Microsoft Azure:

Method 1: From Azure PowerShell modules installed in a computer.

Bg1624

Method 2: From Azure Cloud Shell using browsers.

Bg1625

Create a new Azure vNet

1. In this case, we will first create a resource group. You can skip this step and fill in your resource group details in the next cmdlets if you have one.

New-AzResourceGroup -Name 'Backup-RG' -Location westus

2. Before creating the vNet, we need to create a subnet and store it in a variable. The subnet will not be created in Azure yet.

$subnet = New-AzVirtualNetworkSubnetConfig -Name 'default' -AddressPrefix "172.16.1.0/24"

3. The below cmdlet will create a vNet and add the above subnet to it.

New-AzVirtualNetwork `
-Name 'backup-vnet' `
-ResourceGroupName 'Backup-RG' `
-Location westus `
-AddressPrefix "172.16.0.0/16" `
-Subnet $subnet

Output:

New-AzVirtualNetwork `
>> -Name 'backup-vnet' `
>> -ResourceGroupName 'Backup-RG' `
>> -Location westus `
>> -AddressPrefix "172.16.0.0/16" `
>> -Subnet $subnet

Name                   : backup-vnet
ResourceGroupName      : Backup-RG
Location               : westus
Id                     : /subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e/resourceGroups/Backup-RG/providers/Microsoft.Network/virtualNetworks/backup-vnet
Etag                   : W/"b9182ff5-cf6d-4497-9691-21a2f6a28e72"
ResourceGuid           : f4c88141-7e04-4017-ac2c-6e7edd271a64
ProvisioningState      : Succeeded
Tags                   : 
AddressSpace           : {
                           "AddressPrefixes": [
                             "172.16.0.0/16"
                           ]
                         }
DhcpOptions            : {}
FlowTimeoutInMinutes   : null
Subnets                : [
                           {
                             "Delegations": [],
                             "Name": "default",
                             "Etag": "W/\"b9182ff5-cf6d-4497-9691-21a2f6a28e72\"",
                             "Id": "/subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e/resourceGroups/Backup-RG/providers/Microsoft.Network/virtualNetworks/backup-vnet/subnets/default",
                             "AddressPrefix": [
                               "172.16.1.0/24"
                             ],
                             "IpConfigurations": [],
                             "ServiceAssociationLinks": [],
                             "ResourceNavigationLinks": [],
                             "ServiceEndpoints": [],
                             "ServiceEndpointPolicies": [],
                             "PrivateEndpoints": [],
                             "ProvisioningState": "Succeeded",
                             "PrivateEndpointNetworkPolicies": "Disabled",
                             "PrivateLinkServiceNetworkPolicies": "Enabled",
                             "IpAllocations": []
                           }
                         ]
VirtualNetworkPeerings : []
EnableDdosProtection   : false
DdosProtectionPlan     : null
ExtendedLocation       : null
ADVERTISEMENT

How do you know it works ?

Run the following command to get vNet information from PowerShell.

Get-AzVirtualNetwork | Select-Object name, ResourceGroupName, Location -ExpandProperty AddressSpace   

Name                : backup-vnet
ResourceGroupName   : Backup-RG
Location            : westus
AddressPrefixes     : {172.16.0.0/16}
AddressPrefixesText : [
                        "172.16.0.0/16"
                      ]

Or, you can visit Azure Portal to verify it works.

Bg1628

Conclusion

The process to create a VNET in Azure using PowerShell happens in reverse order as we first create the subnet in memory and after creating the actual subnet.

ADVERTISEMENT
5/5 - (1 vote)
Previous Post

How to Set Azure Default Resource Group Using PowerShell

Next Post

How to Hide The Yellow Warning Output in PowerShell

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

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

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory