代码之家  ›  专栏  ›  技术社区  ›  Galet

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

  •  0
  • Galet  · 技术社区  · 7 年前

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

    我在下面的模板中使用了具有多个端口的destinationPortRange,而不是具有单个端口的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运行上述模板时,由于以下错误,我无法继续

    模板部署“test”根据 验证程序。跟踪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 回复  |  直到 7 年前
        1
  •  1
  •   4c74356b41    7 年前

    错误是由于错误的安全规则名称造成的。