< Back
New-AzureRmVirtualNetwork
Post
NAME New-AzureRmVirtualNetwork
SYNOPSIS
Creates a virtual network.
SYNTAX
New-AzureRmVirtualNetwork -AddressPrefix <System.Collections.Generic.List`1[System.String]> [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-DnsServer <System.Collections.Generic.List`1[System.String]>] [-EnableDDoSProtection] [-EnableVmProtection] [-Force] -Location <String> -Name
<String> -ResourceGroupName <String> [-Subnet <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSSubnet]>] [-Tag
<Hashtable>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The New-AzureRmVirtualNetwork cmdlet creates an Azure virtual network.
PARAMETERS
-AddressPrefix <System.Collections.Generic.List`1[System.String]>
Specifies a range of IP addresses for a virtual network.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-AsJob [<SwitchParameter>]
Run cmdlet in the background
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DnsServer <System.Collections.Generic.List`1[System.String]>
Specifies the DNS server for a subnet.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-EnableDDoSProtection [<SwitchParameter>]
A switch parameter which represents if DDoS protection is enabled or not.
Required? false
Position? named
Default value False
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-EnableVmProtection [<SwitchParameter>]
A switch parameter which represents if Vm protection is enabled or not.
Required? false
Position? named
Default value False
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Forces the command to run without asking for user confirmation.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Location <String>
Specifies the region for the virtual network.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Name <String>
Specifies the name of the virtual network that this cmdlet creates.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ResourceGroupName <String>
Specifies the name of a resource group to contain the virtual network.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Subnet <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSSubnet]>
Specifies a list of subnets to associate with the virtual network.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Tag <Hashtable>
Key-value pairs in the form of a hash table. For example:
@{key0="value0";key1=$null;key2="value2"}
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not accept any input.
OUTPUTS
Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork
NOTES
1: Create a virtual network with two subnets
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24"
New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet
This example creates a virtual network with two subnets. First, a new resource group is created in the centralus region. Then, the example creates
in-memory representations of two subnets. The New-AzureRmVirtualNetworkSubnetConfig cmdlet will not create any subnet on the server side. There is
one subnet called frontendSubnet and one subnet called backendSubnet. The New-AzureRmVirtualNetwork cmdlet then creates a virtual network using
the CIDR 10.0.0.0/16 as the address prefix and two subnets.
2: Create a virtual network with DNS settings
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24"
New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet -DnsServer 10.0.1.5,10.0.1.6
This example create a virtual network with two subnets and two DNS servers. The effect of specifying the DNS servers on the virtual network is
that the NICs/VMs that are deployed into this virtual network inherit these DNS servers as defaults. These defaults can be overwritten per NIC
through a NIC-level setting. If no DNS servers are specified on a VNET and no DNS servers on the NICs, then the default Azure DNS servers are used
for DNS resolution.
3: Create a virtual network with a subnet referencing a network security group
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" -Access Allow -Protocol Tcp -Direction
Inbound -Priority 100 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$networkSecurityGroup = New-AzureRmNetworkSecurityGroup -ResourceGroupName TestResourceGroup -Location centralus -Name "NSG-FrontEnd"
-SecurityRules $rdpRule
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24" -NetworkSecurityGroup
$networkSecurityGroup
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24" -NetworkSecurityGroup
$networkSecurityGroup
New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet
This example creates a virtual network with subnets that reference a network security group. First, the example creates a resource group as a
container for the resources that will be created. Then, a network security group is created that allows inbound RDP access, but otherwise enforces
the default network security group rules. The New-AzureRmVirtualNetworkSubnetConfig cmdlet then creates in-memory representations of two subnets
that both reference the network security group that was created. The New-AzureRmVirtualNetwork command then creates the virtual network.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... ualnetwork
Get-AzureRmVirtualNetwork
Remove-AzureRmVirtualNetwork
Reset-AzureRmVirtualNetworkGateway
SYNOPSIS
Creates a virtual network.
SYNTAX
New-AzureRmVirtualNetwork -AddressPrefix <System.Collections.Generic.List`1[System.String]> [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-DnsServer <System.Collections.Generic.List`1[System.String]>] [-EnableDDoSProtection] [-EnableVmProtection] [-Force] -Location <String> -Name
<String> -ResourceGroupName <String> [-Subnet <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSSubnet]>] [-Tag
<Hashtable>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The New-AzureRmVirtualNetwork cmdlet creates an Azure virtual network.
PARAMETERS
-AddressPrefix <System.Collections.Generic.List`1[System.String]>
Specifies a range of IP addresses for a virtual network.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-AsJob [<SwitchParameter>]
Run cmdlet in the background
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DnsServer <System.Collections.Generic.List`1[System.String]>
Specifies the DNS server for a subnet.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-EnableDDoSProtection [<SwitchParameter>]
A switch parameter which represents if DDoS protection is enabled or not.
Required? false
Position? named
Default value False
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-EnableVmProtection [<SwitchParameter>]
A switch parameter which represents if Vm protection is enabled or not.
Required? false
Position? named
Default value False
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Forces the command to run without asking for user confirmation.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Location <String>
Specifies the region for the virtual network.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Name <String>
Specifies the name of the virtual network that this cmdlet creates.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ResourceGroupName <String>
Specifies the name of a resource group to contain the virtual network.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Subnet <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSSubnet]>
Specifies a list of subnets to associate with the virtual network.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Tag <Hashtable>
Key-value pairs in the form of a hash table. For example:
@{key0="value0";key1=$null;key2="value2"}
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
This cmdlet does not accept any input.
OUTPUTS
Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork
NOTES
1: Create a virtual network with two subnets
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24"
New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet
This example creates a virtual network with two subnets. First, a new resource group is created in the centralus region. Then, the example creates
in-memory representations of two subnets. The New-AzureRmVirtualNetworkSubnetConfig cmdlet will not create any subnet on the server side. There is
one subnet called frontendSubnet and one subnet called backendSubnet. The New-AzureRmVirtualNetwork cmdlet then creates a virtual network using
the CIDR 10.0.0.0/16 as the address prefix and two subnets.
2: Create a virtual network with DNS settings
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24"
New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet -DnsServer 10.0.1.5,10.0.1.6
This example create a virtual network with two subnets and two DNS servers. The effect of specifying the DNS servers on the virtual network is
that the NICs/VMs that are deployed into this virtual network inherit these DNS servers as defaults. These defaults can be overwritten per NIC
through a NIC-level setting. If no DNS servers are specified on a VNET and no DNS servers on the NICs, then the default Azure DNS servers are used
for DNS resolution.
3: Create a virtual network with a subnet referencing a network security group
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$rdpRule = New-AzureRmNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" -Access Allow -Protocol Tcp -Direction
Inbound -Priority 100 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$networkSecurityGroup = New-AzureRmNetworkSecurityGroup -ResourceGroupName TestResourceGroup -Location centralus -Name "NSG-FrontEnd"
-SecurityRules $rdpRule
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24" -NetworkSecurityGroup
$networkSecurityGroup
$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24" -NetworkSecurityGroup
$networkSecurityGroup
New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet
$frontendSubnet,$backendSubnet
This example creates a virtual network with subnets that reference a network security group. First, the example creates a resource group as a
container for the resources that will be created. Then, a network security group is created that allows inbound RDP access, but otherwise enforces
the default network security group rules. The New-AzureRmVirtualNetworkSubnetConfig cmdlet then creates in-memory representations of two subnets
that both reference the network security group that was created. The New-AzureRmVirtualNetwork command then creates the virtual network.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... ualnetwork
Get-AzureRmVirtualNetwork
Remove-AzureRmVirtualNetwork
Reset-AzureRmVirtualNetworkGateway