如何在 ARM 模板中放置多个目标端口范围?
How to put multiple destination port ranges in ARM templates?
我有一长串目标端口范围,12000-13000, 2000-3000, 443
。如何将所有这些端口范围放入 ARM 模板中?
{
"name": "test-nsg",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2020-06-01",
"location": "[variables('location')]",
"properties": {
"securityRules": [ {
"name": "Allow ports",
"properties": {
"priority": 1000,
"sourceAddressPrefix": "*",
"protocol": "TCP",
"destinationPortRanges": [
"443",
""
],
"access": "Allow",
"direction": "Inbound",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
}]
}
}
您可以在您的 arm 模板中传递多个目标端口范围,如下所示
"destinationPortRanges": ["1200-1300","2000-3000","443","22"]
或者,您可以通过为数组类型的端口创建参数并在资源块中调用这些参数来传递这些多个目标端口范围值,如下所示
"parameters":{
"port":{
"type":"array",
"defaultValue":[
"1200-1300",
"15000-16000",
"443"
]
}
}
在资源块中:
"destinationPortRanges": "[parameters('port')]"
我有一长串目标端口范围,12000-13000, 2000-3000, 443
。如何将所有这些端口范围放入 ARM 模板中?
{
"name": "test-nsg",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2020-06-01",
"location": "[variables('location')]",
"properties": {
"securityRules": [ {
"name": "Allow ports",
"properties": {
"priority": 1000,
"sourceAddressPrefix": "*",
"protocol": "TCP",
"destinationPortRanges": [
"443",
""
],
"access": "Allow",
"direction": "Inbound",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
}]
}
}
您可以在您的 arm 模板中传递多个目标端口范围,如下所示
"destinationPortRanges": ["1200-1300","2000-3000","443","22"]
或者,您可以通过为数组类型的端口创建参数并在资源块中调用这些参数来传递这些多个目标端口范围值,如下所示
"parameters":{
"port":{
"type":"array",
"defaultValue":[
"1200-1300",
"15000-16000",
"443"
]
}
}
在资源块中:
"destinationPortRanges": "[parameters('port')]"