[英]Azure Powershell not creating NSG rules with multiple ports
我向NSG添加了一個安全規則,該規則允許訪問端口4239、1128、1129。 通過Azure門戶,它可以工作。 通過Powershell,它拒絕了。
我正在使用以下代碼來獲取NSG,添加安全規則並更新NSG。
$nsg = Get-AzNetworkSecurityGroup -Name "BITH-DEV-T1NSG" -
ResourceGroupName "RG-BITH-HANA-POC"
$nsg | Add-AzNetworkSecurityRuleConfig -Name "SUM6" -Description "Allow
SUM" -Access "Allow" -Protocol * -Direction "Inbound" -Priority "105" -
SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -
DestinationPortRange "1128,1129,4239"
$nsg | Set-AzNetworkSecurityGroup
更新NSG時,出現以下錯誤。
Set-AzNetworkSecurityGroup : Security rule has invalid Port range. Value
provided: 4239,1128,1129. Value should be an integer OR integer range
with '-' delimiter.Valid range 0-65535.
是否可以通過Powershell向NSG添加自定義范圍?
您應該提供一個數組作為輸入,而不是帶逗號的字符串:
-DestinationPortRange (1128, 1129, 4239)
或使用"1128", "1129", "4239"
如果沒有將它們自動轉換為字符串)。 DestinationPortRange
接受一個數組。
閱讀: https : //docs.microsoft.com/zh-cn/powershell/module/az.network/add-aznetworksecurityruleconfig?view=azps-2.2.0#parameters
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.