如何在ARM模板的单个NSG SecurityRule中使用多个目标端口

时间:2018-08-22 11:26:19

标签: azure arm-template network-security-groups

我想在NSG中使用单个securityRule,而不是对每个目标端口使用单独的规则。

我在下面的模板中使用了具有多个端口的destinationPortRanges,而不是具有单个端口的destinationPortRange。

{
    "name": "test-nsg-005",
    "type": "Microsoft.Network/networkSecurityGroups",
    "apiVersion": "2018-06-01",
    "location": "[variables('location')]",
    "properties": {
        "securityRules": [                {
                "name": "Allow ports",
                "properties": {
                    "priority": 1000,
                    "sourceAddressPrefix": "*",
                    "protocol": "TCP",
                    "destinationPortRanges": [
                        "22",
                        "443"                            
                    ],
                    "access": "Allow",
                    "direction": "Inbound",
                    "sourcePortRange": "*",
                    "destinationAddressPrefix": "*"
                }
            }]
    }
}  

当我尝试使用Azure CLI运行上述模板时,由于以下错误,我无法继续操作

  

模板部署“测试”根据   验证程序。跟踪ID为   '0ee64525-9d2b-49cb-bac7-24baa73ac1d7'。有关详细信息,请参见内部错误。   有关用法的详细信息,请参见https://aka.ms/arm-deploy

更新:-

{"error":{"code":"InvalidTemplateDeployment","message":"The template deployment \'test\' is not valid according to the validation procedure. The tracking id is \'1e7527bc-6c7f-4aa9-8ed6-235402a229b7\'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details.","details":[{"code":"InvalidResourceName","message":"Resource name Allow ports is invalid. The name can be up to 80 characters long. It must begin with a word character, and it must end with a word character or with \'_\'. The name may contain word characters or \'.\', \'-\', \'_\'.","details":[]}]}}'
msrest.exceptions : The template deployment 'test' is not valid according to the validation procedure. The tracking id is '1e7527bc-6c7f-4aa9-8ed6-235402a229b7'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details.

我遇到了以上错误,重命名了安全规则名称后,问题得到解决。

1 个答案:

答案 0 :(得分:1)

该错误是由于安全规则名称错误所致。