Dan*_*örk 2 powershell azure azure-nsg
使用 powershell 在 Azure 中创建 NSG 规则时,我尝试将多个 CIDR 添加到 SourceAddressPrefix。我在运行 Set-AzNetworkSecurityGroup 时收到错误消息,因此它在使用 New-AzNetworkSecurityRuleConfig 创建规则时接受该值。有人知道如何解决吗?注意:是的,我知道我可以创建多个规则,但我想尽可能避免这种情况。
使用门户可以正常工作,但使用 Powershell 时会收到错误消息。
尝试1:
$rule3 = New-AzNetworkSecurityRuleConfig -Name "In-SandNet-Vnet-Any-Any" `
-Access Allow -Protocol * -Direction Inbound -Priority 1000 -SourceAddressPrefix {"10.0.0.0/8","192.168.0.0/16"} `
-SourcePortRange * -DestinationAddressPrefix VirtualNetwork -DestinationPortRange *
$nsg.SecurityRules.Add($rule3)
Set-AzNetworkSecurityGroup -NetworkSecurityGroup $nsg
Run Code Online (Sandbox Code Playgroud)
错误信息:
xxx has invalid Address prefix. Value provided: "10.0.0.0/8","192.168.0.0/16"
Run Code Online (Sandbox Code Playgroud)
尝试2:
$rule3 = New-AzNetworkSecurityRuleConfig -Name "In-SandNet-Vnet-Any-Any" `
-Access Allow -Protocol * -Direction Inbound -Priority 1000 -SourceAddressPrefix "10.0.0.0/8,192.168.0.0/16" `
-SourcePortRange * -DestinationAddressPrefix VirtualNetwork -DestinationPortRange *
$nsg.SecurityRules.Add($rule3)
Set-AzNetworkSecurityGroup -NetworkSecurityGroup $nsg
Run Code Online (Sandbox Code Playgroud)
错误信息(同样的错误信息):
xxx has invalid Address prefix. Value provided: "10.0.0.0/8","192.168.0.0/16"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1502 次 |
| 最近记录: |