0% found this document useful (0 votes)
21 views2 pages

Sure! Here's How You Can Create A V

Uploaded by

Dario Baskarad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Sure! Here's How You Can Create A V

Uploaded by

Dario Baskarad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sure!

Here's how you can create a virtual network and a subnet in Azure using Azure
PowerShell.

### Step 1: **Login to Azure**


First, log in to your Azure account using Azure PowerShell:

```powershell
Connect-AzAccount
```

### Step 2: **Set up variables**


Define some variables that will be used in the creation process:

```powershell
$resourceGroup = "myResourceGroup"
$location = "EastUS"
$vnetName = "myVNet"
$subnetName = "mySubnet"
$vnetAddressPrefix = "10.0.0.0/16" # Address space for the virtual network
$subnetAddressPrefix = "10.0.1.0/24" # Address range for the subnet
```

### Step 3: **Create a Resource Group**


If you don’t already have a resource group, you need to create one. A resource
group is required to hold the resources like virtual networks and subnets.

```powershell
New-AzResourceGroup -Name $resourceGroup -Location $location
```

### Step 4: **Create a Virtual Network**


Create the virtual network using the `New-AzVirtualNetwork` command:

```powershell
# Create the subnet configuration
$subnetConfig = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix
$subnetAddressPrefix

# Create the virtual network with the subnet


New-AzVirtualNetwork -ResourceGroupName $resourceGroup `
-Location $location `
-Name $vnetName `
-AddressPrefix $vnetAddressPrefix `
-Subnet $subnetConfig
```

### Step 5: **Verify the Virtual Network and Subnet**


To verify that the virtual network and the subnet have been created:

```powershell
Get-AzVirtualNetwork -ResourceGroupName $resourceGroup -Name $vnetName
```

This will display information about the virtual network and its subnets.

### Explanation:

- **`New-AzResourceGroup`**: Creates a new resource group to hold your network


resources.
- **`New-AzVirtualNetworkSubnetConfig`**: Defines a subnet configuration with the
given address prefix.
- **`New-AzVirtualNetwork`**: Creates a virtual network with the specified address
space and the defined subnet.
- **`Get-AzVirtualNetwork`**: Retrieves details of the created virtual network and
its subnets.

This will create a virtual network named `myVNet` with a subnet called `mySubnet`
in the resource group `myResourceGroup`.

You might also like