你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Add-AzVirtualNetworkSubnetConfig
Adds a subnet configuration to a virtual network.
Syntax
Add-AzVirtualNetworkSubnetConfig
-Name <String>
-VirtualNetwork <PSVirtualNetwork>
-AddressPrefix <String[]>
[-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>]
Add-AzVirtualNetworkSubnetConfig
-Name <String>
-VirtualNetwork <PSVirtualNetwork>
-AddressPrefix <String[]>
[-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 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
-AddressPrefix
Specifies a range of IP addresses for a subnet configuration.
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultOutboundAccess
Default outbound connectivity for all VMs in the subnet
Type: | Nullable<T>[Boolean] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Delegation
List of services that have permission to perform operations on this subnet.
Type: | PSDelegation[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-InputObject
Specifies the nat gateway associated with the subnet configuration.
Type: | PSNatGateway |
Aliases: | NatGateway |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-IpAllocation
Specifies IpAllocations for a subnet.
Type: | PSIpAllocation[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
Specifies the name of the subnet configuration to add.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-NetworkIdentifier
NetworkIdentifier Value for ServiceEndpoint
Type: | PSResourceId |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-NetworkSecurityGroup
Specifies a NetworkSecurityGroup object. This cmdlet adds a virtual network subnet configuration to the object that this parameter specifies.
Type: | PSNetworkSecurityGroup |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-NetworkSecurityGroupId
Specifies the ID of a network security group.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PrivateEndpointNetworkPoliciesFlag
Configure to enable or disable applying network policies on private endpoint in the subnet. Default value is Disabled.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PrivateLinkServiceNetworkPoliciesFlag
Configure to enable or disable applying network policies on private link service in the subnet.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceId
Specifies the Id of NAT Gateway resource associated with the subnet configuration.
Type: | String |
Aliases: | NatGatewayId |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RouteTable
Type: | PSRouteTable |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-RouteTableId
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServiceEndpoint
Service Endpoint Value
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServiceEndpointConfig
Service Endpoint with NetworkIdentifier Value
Type: | PSServiceEndpoint[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServiceEndpointPolicy
Service Endpoint Policies
Type: | PSServiceEndpointPolicy[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-VirtualNetwork
Specifies the VirtualNetwork object in which to add a subnet configuration.
Type: | PSVirtualNetwork |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
String[]