Edit

Share via


New-AzVirtualNetworkSubnetConfig

Creates a virtual network subnet configuration.

Syntax

SetByResource (Default)

New-AzVirtualNetworkSubnetConfig
    -Name <String>
    [-AddressPrefix <String[]>]
    [-IpamPoolPrefixAllocation <PSIpamPoolPrefixAllocation[]>]
    [-NetworkSecurityGroup <PSNetworkSecurityGroup>]
    [-RouteTable <PSRouteTable>]
    [-InputObject <PSNatGateway>]
    [-ServiceEndpoint <String[]>]
    [-NetworkIdentifier <PSResourceId>]
    [-ServiceEndpointConfig <PSServiceEndpoint[]>]
    [-ServiceEndpointPolicy <PSServiceEndpointPolicy[]>]
    [-Delegation <PSDelegation[]>]
    [-PrivateEndpointNetworkPoliciesFlag <String>]
    [-PrivateLinkServiceNetworkPoliciesFlag <String>]
    [-IpAllocation <PSIpAllocation[]>]
    [-DefaultOutboundAccess <Boolean>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

SetByResourceId

New-AzVirtualNetworkSubnetConfig
    -Name <String>
    [-AddressPrefix <String[]>]
    [-IpamPoolPrefixAllocation <PSIpamPoolPrefixAllocation[]>]
    [-NetworkSecurityGroupId <String>]
    [-RouteTableId <String>]
    [-ResourceId <String>]
    [-ServiceEndpoint <String[]>]
    [-NetworkIdentifier <PSResourceId>]
    [-ServiceEndpointConfig <PSServiceEndpoint[]>]
    [-ServiceEndpointPolicy <PSServiceEndpointPolicy[]>]
    [-Delegation <PSDelegation[]>]
    [-PrivateEndpointNetworkPoliciesFlag <String>]
    [-PrivateLinkServiceNetworkPoliciesFlag <String>]
    [-IpAllocation <PSIpAllocation[]>]
    [-DefaultOutboundAccess <Boolean>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The New-AzVirtualNetworkSubnetConfig cmdlet creates a virtual network subnet configuration.

Examples

Example 1: Create a virtual network with two subnets and a network security group

New-AzResourceGroup -Name TestResourceGroup -Location centralus

$rdpRule = New-AzNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" `
   -Access Allow -Protocol Tcp -Direction Inbound -Priority 100 `
   -SourceAddressPrefix Internet -SourcePortRange * `
   -DestinationAddressPrefix * -DestinationPortRange 3389

$networkSecurityGroup = New-AzNetworkSecurityGroup -ResourceGroupName TestResourceGroup `
  -Location centralus -Name "NSG-FrontEnd" -SecurityRules $rdpRule

$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name frontendSubnet `
    -AddressPrefix "10.0.1.0/24" -NetworkSecurityGroup $networkSecurityGroup

$backendSubnet = New-AzVirtualNetworkSubnetConfig -Name backendSubnet `
    -AddressPrefix "10.0.2.0/24" -NetworkSecurityGroup $networkSecurityGroup

$pip = New-AzPublicIpAddress -Name "pip" -ResourceGroupName "natgateway_test" `
   -Location "eastus2" -Sku "Standard" -IdleTimeoutInMinutes 4 -AllocationMethod "static"

$natgateway = New-AzNatGateway -ResourceGroupName "natgateway_test" -Name "nat_gateway" `
   -IdleTimeoutInMinutes 4 -Sku "Standard" -Location "eastus2" -PublicIpAddress $pip

$natGatewaySubnet = New-AzVirtualNetworkSubnetConfig -Name natGatewaySubnet `
   -AddressPrefix "10.0.3.0/24" -InputObject $natGateway

New-AzVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup `
    -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet,$backendSubnet,$natGatewaySubnet

This example creates two new subnet configurations using the New-AzVirtualNetworkSubnetConfig cmdlet, and then uses them to create a virtual network. The New-AzVirtualNetworkSubnetConfig template only creates an in-memory representation of the subnet. In this example, the frontendSubnet has CIDR 10.0.1.0/24 and references a network security group that allows RDP access. The backendSubnet has CIDR 10.0.2.0/24 and references the same network security group.

Parameters

-AddressPrefix

Specifies a range of IP addresses for a subnet configuration.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultOutboundAccess

Default outbound connectivity for all VMs in the subnet

Parameter properties

Type:

Nullable<T>[Boolean]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Delegation

List of services that have permission to perform operations on this subnet.

Parameter properties

Type:

PSDelegation[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-InputObject

Specifies the nat gateway associated with the subnet configuration

Parameter properties

Type:PSNatGateway
Default value:None
Supports wildcards:False
DontShow:False
Aliases:NatGateway

Parameter sets

SetByResource
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-IpAllocation

Specifies IpAllocations for a subnet.

Parameter properties

Type:

PSIpAllocation[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-IpamPoolPrefixAllocation

IpamPool to auto allocate from for subnet address prefixes.

Parameter properties

Type:

PSIpamPoolPrefixAllocation[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies the name of the subnet configuration to create.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-NetworkIdentifier

NetworkIdentifier Value for ServiceEndpoint

Parameter properties

Type:PSResourceId
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-NetworkSecurityGroup

Specifies a NetworkSecurityGroup object.

Parameter properties

Type:PSNetworkSecurityGroup
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetByResource
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-NetworkSecurityGroupId

Specifies the ID of a network security group.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetByResourceId
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PrivateEndpointNetworkPoliciesFlag

Configure to enable or disable applying network policies on private endpoint in the subnet. Default value is Disabled.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-PrivateLinkServiceNetworkPoliciesFlag

Configure to enable or disable applying network policies on private link service in the subnet.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResourceId

Specifies the Id of NAT Gateway resource associated with the subnet configuration.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:NatGatewayId

Parameter sets

SetByResourceId
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-RouteTable

Specifies the route table associated with the subnet configuration.

Parameter properties

Type:PSRouteTable
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetByResource
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-RouteTableId

Specifies the ID of the route table associated with the subnet configuration.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

SetByResourceId
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ServiceEndpoint

Service Endpoint Value

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ServiceEndpointConfig

Service Endpoint with NetworkIdentifier Value

Parameter properties

Type:

PSServiceEndpoint[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ServiceEndpointPolicy

Service Endpoint Policies

Parameter properties

Type:

PSServiceEndpointPolicy[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

PSNetworkSecurityGroup

PSRouteTable

PSNatGateway

String

PSServiceEndpointPolicy

PSDelegation

Outputs

PSSubnet