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

Set-AzureNetworkSecurityRule

在网络安全组中添加或修改网络安全规则。

注意

本文档中引用的 cmdlet 用于管理使用 Azure Service Manager (ASM) API 的旧 Azure 资源。 创建新的资源时,不建议使用此旧版 PowerShell 模块,因为 ASM 计划停用。 有关详细信息,请参阅 Azure Service Manager 停用

Az PowerShell 模块是推荐的 PowerShell 模块,用于使用 PowerShell 管理 Azure 资源管理器 (ARM) 资源。

语法

Set-AzureNetworkSecurityRule
   -Name <String>
   -Type <String>
   -Priority <Int32>
   -Action <String>
   -SourceAddressPrefix <String>
   -SourcePortRange <String>
   -DestinationAddressPrefix <String>
   -DestinationPortRange <String>
   -Protocol <String>
   -NetworkSecurityGroup <INetworkSecurityGroup>
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

说明

Set-AzureNetworkSecurityRule cmdlet 在网络安全组中添加或修改 Azure 网络安全规则。

参数

-Action

指定网络安全规则的操作。 有效值为:允许和拒绝。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-DestinationAddressPrefix

指定网络安全规则的目标 IP 范围的无类别域际路由选择(CIDR)地址。 星号 \ 指定任何 IP 地址。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-DestinationPortRange

指定网络安全规则的目标端口范围。 有效值由 0 到 65535 的整数组成。 可以指定单个值,也可以以 LowerNumber-HigherNumber 格式指定范围。 连字符分隔两个值。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-Name

指定此 cmdlet 添加或修改的网络安全规则的名称。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-NetworkSecurityGroup

指定此 cmdlet 修改的网络安全组。 若要获取 INetworkSecurityGroup 对象,请使用 Get-AzureNetworkSecurityGroup cmdlet。

类型:INetworkSecurityGroup
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-Priority

指定网络安全规则的优先级。 有效值为:100 到 4096 的整数。

类型:Int32
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-Profile

指定此 cmdlet 从中读取的 Azure 配置文件。 如果未指定配置文件,此 cmdlet 将从本地默认配置文件中读取。

类型:AzureSMProfile
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Protocol

指定网络安全规则的协议。 有效值为:

  • TCP
  • UDP
类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-SourceAddressPrefix

指定网络安全规则的源 IP 范围的 CIDR 地址。 星号 \ 指定任何 IP 地址。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-SourcePortRange

指定网络安全规则的源端口范围。 有效值由 0 到 65535 的整数组成。 可以指定单个值,也可以以 LowerNumber-HigherNumber 格式指定范围。 连字符分隔两个值。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-Type

指定网络安全规则的连接类型。 有效值为:入站和出站。

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False