< Back
Set-AzureRmVirtualNetworkSubnetConfig
Post
NAME Set-AzureRmVirtualNetworkSubnetConfig
SYNOPSIS
Configures the goal state for a subnet configuration in a virtual network.
SYNTAX
Set-AzureRmVirtualNetworkSubnetConfig -AddressPrefix <String> [-DefaultProfile <IAzureContextContainer>] -Name <String> [-NetworkSecurityGroup
<PSNetworkSecurityGroup>] [-RouteTable <PSRouteTable>] [-ServiceEndpoint <System.Collections.Generic.List`1[System.String]>] -VirtualNetwork
<PSVirtualNetwork> [<CommonParameters>]
Set-AzureRmVirtualNetworkSubnetConfig -AddressPrefix <String> [-DefaultProfile <IAzureContextContainer>] -Name <String> [-NetworkSecurityGroupId
<String>] [-RouteTableId <String>] [-ServiceEndpoint <System.Collections.Generic.List`1[System.String]>] -VirtualNetwork <PSVirtualNetwork>
[<CommonParameters>]
DESCRIPTION
The Set-AzureRmVirtualNetworkSubnetConfig cmdlet configures the goal state for a subnet configuration in an Azure virtual network.
PARAMETERS
-AddressPrefix <String>
Specifies a range of IP addresses for a subnet configuration.
Required? true
Position? named
Default value None
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
-Name <String>
Specifies the name of a subnet configuration that this cmdlet configures.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-NetworkSecurityGroup <PSNetworkSecurityGroup>
Specifies a NetworkSecurityGroup object.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-NetworkSecurityGroupId <String>
Specifies the ID of a network security group.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RouteTable <PSRouteTable>
Specifies the route table object that is associated with the network security group.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RouteTableId <String>
Specifies the ID of the route table object that is associated with the network security group.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ServiceEndpoint <System.Collections.Generic.List`1[System.String]>
Service Endpoint Value
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-VirtualNetwork <PSVirtualNetwork>
Specifies the VirtualNetwork object that contains the subnet configuration.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
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
PSVirtualNetwork
Parameter 'VirtualNetwork' accepts value of type 'PSVirtualNetwork' from the pipeline
OUTPUTS
Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork
NOTES
1: Modify the address prefix of a subnet
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$virtualNetwork = New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup
-Location centralus -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet
Set-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.3.0/23"
$virtualNetwork | Set-AzureRmVirtualNetwork
This example creates a virtual network with one subnet. Then is calls Set-AzureRmVirtualNetworkSubnetConfig to modify the AddressPrefix of
the subnet. This only impacts the in-memory representation of the virtual network. Set-AzureRmVirtualNetwork is then called to modify
the virtual network in Azure.
2: Add a network security group to a subnet
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$virtualNetwork = New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup
-Location centralus -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet
$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
Set-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -VirtualNetwork $virtualNetwork -AddressPrefix
"10.0.1.0/24" -NetworkSecurityGroup $networkSecurityGroup
$virtualNetwork | Set-AzureRmVirtualNetwork
This example creates a resource group with one virtual network containing just one subnet. It then creates a network security group with an
allow rule for RDP traffic. The Set-AzureRmVirtualNetworkSubnetConfig cmdlet is used to modify the in-memory representation of the
frontend subnet so that it points to the newly created network security group. The Set-AzureRmVirtualNetwork cmdlet is then called to write
the modified state back to the service.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... bnetconfig
Add-AzureRmVirtualNetworkSubnetConfig
Get-AzureRmVirtualNetworkSubnetConfig
New-AzureRmVirtualNetworkSubnetConfig
Remove-AzureRmVirtualNetworkSubnetConfig
SYNOPSIS
Configures the goal state for a subnet configuration in a virtual network.
SYNTAX
Set-AzureRmVirtualNetworkSubnetConfig -AddressPrefix <String> [-DefaultProfile <IAzureContextContainer>] -Name <String> [-NetworkSecurityGroup
<PSNetworkSecurityGroup>] [-RouteTable <PSRouteTable>] [-ServiceEndpoint <System.Collections.Generic.List`1[System.String]>] -VirtualNetwork
<PSVirtualNetwork> [<CommonParameters>]
Set-AzureRmVirtualNetworkSubnetConfig -AddressPrefix <String> [-DefaultProfile <IAzureContextContainer>] -Name <String> [-NetworkSecurityGroupId
<String>] [-RouteTableId <String>] [-ServiceEndpoint <System.Collections.Generic.List`1[System.String]>] -VirtualNetwork <PSVirtualNetwork>
[<CommonParameters>]
DESCRIPTION
The Set-AzureRmVirtualNetworkSubnetConfig cmdlet configures the goal state for a subnet configuration in an Azure virtual network.
PARAMETERS
-AddressPrefix <String>
Specifies a range of IP addresses for a subnet configuration.
Required? true
Position? named
Default value None
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
-Name <String>
Specifies the name of a subnet configuration that this cmdlet configures.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-NetworkSecurityGroup <PSNetworkSecurityGroup>
Specifies a NetworkSecurityGroup object.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-NetworkSecurityGroupId <String>
Specifies the ID of a network security group.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RouteTable <PSRouteTable>
Specifies the route table object that is associated with the network security group.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RouteTableId <String>
Specifies the ID of the route table object that is associated with the network security group.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-ServiceEndpoint <System.Collections.Generic.List`1[System.String]>
Service Endpoint Value
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-VirtualNetwork <PSVirtualNetwork>
Specifies the VirtualNetwork object that contains the subnet configuration.
Required? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
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
PSVirtualNetwork
Parameter 'VirtualNetwork' accepts value of type 'PSVirtualNetwork' from the pipeline
OUTPUTS
Microsoft.Azure.Commands.Network.Models.PSVirtualNetwork
NOTES
1: Modify the address prefix of a subnet
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$virtualNetwork = New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup
-Location centralus -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet
Set-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -VirtualNetwork $virtualNetwork -AddressPrefix "10.0.3.0/23"
$virtualNetwork | Set-AzureRmVirtualNetwork
This example creates a virtual network with one subnet. Then is calls Set-AzureRmVirtualNetworkSubnetConfig to modify the AddressPrefix of
the subnet. This only impacts the in-memory representation of the virtual network. Set-AzureRmVirtualNetwork is then called to modify
the virtual network in Azure.
2: Add a network security group to a subnet
New-AzureRmResourceGroup -Name TestResourceGroup -Location centralus
$frontendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$virtualNetwork = New-AzureRmVirtualNetwork -Name MyVirtualNetwork -ResourceGroupName TestResourceGroup
-Location centralus -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet
$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
Set-AzureRmVirtualNetworkSubnetConfig -Name frontendSubnet -VirtualNetwork $virtualNetwork -AddressPrefix
"10.0.1.0/24" -NetworkSecurityGroup $networkSecurityGroup
$virtualNetwork | Set-AzureRmVirtualNetwork
This example creates a resource group with one virtual network containing just one subnet. It then creates a network security group with an
allow rule for RDP traffic. The Set-AzureRmVirtualNetworkSubnetConfig cmdlet is used to modify the in-memory representation of the
frontend subnet so that it points to the newly created network security group. The Set-AzureRmVirtualNetwork cmdlet is then called to write
the modified state back to the service.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... bnetconfig
Add-AzureRmVirtualNetworkSubnetConfig
Get-AzureRmVirtualNetworkSubnetConfig
New-AzureRmVirtualNetworkSubnetConfig
Remove-AzureRmVirtualNetworkSubnetConfig