Creating a Virtual Network using Azure PowerShell

To execute the desired action, kindly access Windows PowerShell and proceed by selecting “Run as administrator” from the context menu upon right-clicking.

Enter the following commands to create a Virtual Network using Azure PowerShell

Step 1: Set up the Azure services in PowerShell

As the initial step, establish the Azure services within PowerShell environment by executing the following command:

Install-Module Az -Force -AllowClobber

In addition, you may need to adjust the execution policy to ‘RemoteSigned’ by running the following command:

Set-ExecutionPolicy RemoteSigned

Step 2: Connect to your Azure account

To connect to your Azure account, Navigate to your azure portal and search for tenant properties, under that find the tenant Id. copy the tenant Id.

To establish a connection, kindly utilize the “Connect-AzAccount” command in PowerShell, specifying your Tenant ID as follows:

Connect-AzAccount -TenantId <Copy-your-tenantid-here>

It will ask to choose your Azure account and after Authentication is completed, you can navigate back to the PowerShell.

Step 3: Create a Resource Group

Execute the following command in PowerShell to create a new resource group, ensuring to replace <your-resource-group-name> with your desired name and <your-resource-group-location> with the location of your resource group.

New-AzResourceGroup -ResourceGroupName <your-resource-group-name> -Location <your-resource-group-location>

Step 4: Create a Virtual Newtwork in the resource group

Establish a Virtual Network within the designated resource group by executing the following PowerShell command:

$<your-vnet-name> = New-AzVirtualNetwork -ResourceGroupName <your-resource-group-name> -Location <your-resource-group-location> -Name <yTour-vnet-name> -AddressPrefix <address-prefix-of-your-vnet>

Ensure to replace placeholders such as <your-vnet-name>, <your-resource-group-name>, <your-resource-group-location>, and <address-prefix-of-your-vnet> with appropriate values as per your configuration.

Step 5: Check whether the Virtual Network is created or not

Verify the existence of the Virtual Network by executing the following command in the PowerShell environment.

Get-AzVirtualNetwork -Name myVnet001

How to Delete Virtual Network in Azure

We often create virtual networks in Azure to manage and maintain our virtual machines. When the virtual machines or resources are no longer needed, we manage them by deleting the virtual machines, and sometimes we may also find the virtual network is no longer needed. We may find the VNET no longer needed considering the factors including resource usage, project lifecycle, and cost optimization. In this article, let us understand deleting a Virtual Network in Azure with different approaches. Before diving into the topic, let us have an overview of the Virtual network in Azure.

Azure Virtual Network allows its customers to create, manage, monitor, and secure connectivity between Azure resources and their on-premise environments.

Similar Reads

Creating a Virtual Network using Azure PowerShell

To execute the desired action, kindly access Windows PowerShell and proceed by selecting “Run as administrator” from the context menu upon right-clicking....

Deleting a Virtual network using PowerShell

There are multiple ways to create or delete a virtual network. Either we can delete the virtual network from the Azure portal directly or We can use commands to delete the virtual network using the PowerShell. Let us see how to delete a virtual network using PowerShell....

Deleting a Virtual Network using Azure Portal

Here is the detail steps to delete the virtual network using the azure portal....

Conclusion

Deleting Virtual Network can be cost-effective and resource optimisation when it is not longer required but, Ensure and back-up the underlying critical resources with the virtual network....

Delete Virtual Network in Azure – FAQs

Why would I want to delete a virtual network in Azure?...