你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Remove-AzNetworkSecurityRuleConfig

Removes a network security rule from a network security group.

Syntax

Remove-AzNetworkSecurityRuleConfig
      [-Name <String>]
      -NetworkSecurityGroup <PSNetworkSecurityGroup>
      [-DefaultProfile <IAzureContextContainer>]
      [<CommonParameters>]

Description

The Remove-AzNetworkSecurityRuleConfig cmdlet removes a network security rule configuration from an Azure network security group.

Examples

Example 1: Remove a network security rule configuration

$rule1 = New-AzNetworkSecurityRuleConfig -Name "rdp-rule" -Description "Allow RDP" -Access "Allow" -Protocol "Tcp" -Direction "Inbound" -Priority 100 -SourceAddressPrefix "Internet" -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName "TestRG" -Location "westus" -Name "NSG-FrontEnd" -SecurityRules $rule1
Remove-AzNetworkSecurityRuleConfig -Name "rdp-rule" -NetworkSecurityGroup $nsg
$nsg | Set-AzNetworkSecurityGroup

The first command creates a network security rule configuration named rdp-rule, and then stores it in the $rule1 variable. The second command creates a network security group using the rule in $rule1, and then stores the network security group in the $nsg variable. The third command removes the network security rule configuration named rdp-rule from the network security group in $nsg. The forth command saves the change.

Parameters

-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

-Name

Specifies the name of the network security rule configuration that this cmdlet removes.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-NetworkSecurityGroup

Specifies a NetworkSecurityGroup object. This object contains the network security rule configuration to remove.

Type:PSNetworkSecurityGroup
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

PSNetworkSecurityGroup

Outputs

PSNetworkSecurityGroup