Edit

Add-AzVirtualNetworkSubnetConfig

Adds a subnet configuration to a virtual network.

Syntax

SetByResource (Default)

Add-AzVirtualNetworkSubnetConfig
    -Name 
    -VirtualNetwork 
    [-AddressPrefix ]
    [-IpamPoolPrefixAllocation ]
    [-NetworkSecurityGroup ]
    [-RouteTable ]
    [-InputObject ]
    [-ServiceEndpoint ]
    [-NetworkIdentifier ]
    [-ServiceEndpointConfig ]
    [-ServiceEndpointPolicy ]
    [-Delegation ]
    [-PrivateEndpointNetworkPoliciesFlag ]
    [-PrivateLinkServiceNetworkPoliciesFlag ]
    [-IpAllocation ]
    [-DefaultOutboundAccess ]
    [-DefaultProfile ]
    [-AcquirePolicyToken]
    [-ChangeReference ]
    []

SetByResourceId

Add-AzVirtualNetworkSubnetConfig
    -Name 
    -VirtualNetwork 
    [-AddressPrefix ]
    [-IpamPoolPrefixAllocation ]
    [-NetworkSecurityGroupId ]
    [-RouteTableId ]
    [-ResourceId ]
    [-ServiceEndpoint ]
    [-NetworkIdentifier ]
    [-ServiceEndpointConfig ]
    [-ServiceEndpointPolicy ]
    [-Delegation ]
    [-PrivateEndpointNetworkPoliciesFlag ]
    [-PrivateLinkServiceNetworkPoliciesFlag ]
    [-IpAllocation ]
    [-DefaultOutboundAccess ]
    [-DefaultProfile ]
    [-AcquirePolicyToken]
    [-ChangeReference ]
    []

Description

The Add-AzVirtualNetworkSubnetConfig cmdlet adds a subnet configuration to an existing Azure virtual network.

Examples

Example 1: Add a subnet to an existing virtual network

New-AzResourceGroup -Name TestResourceGroup -Location centralus
    $frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
    $virtualNetwork = New-AzVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup -Location centralus -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet
    Add-AzVirtualNetworkSubnetConfig -Name backendSubnet -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.2.0/24"
    $virtualNetwork | Set-AzVirtualNetwork

This example first creates a resource group as a container of the resources to be created. It then creates a subnet configuration and uses it to create a virtual network. The Add-AzVirtualNetworkSubnetConfig is then used to add a subnet to the in-memory representation of the virtual network. The Set-AzVirtualNetwork command updates the existing virtual network with the new subnet.

Example 2: Add a delegation to a subnet being added to an existing virtual network

$vnet = Get-AzVirtualNetwork -Name "myVNet" -ResourceGroupName "myResourceGroup"
$delegation = New-AzDelegation -Name "myDelegation" -ServiceName "Microsoft.Sql/servers"
Add-AzVirtualNetworkSubnetConfig -Name "mySubnet" -VirtualNetwork $vnet -AddressPrefix "10.0.2.0/24" -Delegation $delegation | Set-AzVirtualNetwork

This example first gets an existing vnet. Then, it creates a delegation object in memory. Finally, it creates a new subnet with that delegation that is added to the vnet. The modified configuration is then sent to the server.

Parameters

-AcquirePolicyToken

Acquire an Azure Policy token automatically for this resource operation.

Parameter properties

Type:SwitchParameter
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

-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

-ChangeReference

The change reference resource ID for this resource operation.

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[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 add.

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. This cmdlet adds a virtual network subnet configuration to the object that this parameter specifies.

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

The Add-AzVirtualNetworkSubnetConfig cmdlet adds a subnet configuration to an existing Azure virtual network.

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

The Add-AzVirtualNetworkSubnetConfig cmdlet adds a subnet configuration to an existing Azure virtual network.

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

-VirtualNetwork

Specifies the VirtualNetwork object in which to add a subnet configuration.

Parameter properties

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

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
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

PSVirtualNetwork

String

PSNetworkSecurityGroup

PSRouteTable

String

PSServiceEndpointPolicy

PSDelegation

Outputs

PSVirtualNetwork