【发布时间】:2019-01-28 15:41:40
【问题描述】:
我想在 NSG 中使用单个安全规则,而不是为每个目标端口使用单独的规则。
我在下面的模板中使用了带有多个端口的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.
我得到了上述错误,重命名安全规则名称后,问题得到解决。
【问题讨论】:
-
这是正确的做法,一件事,尝试使用整数数组,而不是字符串:
[ 22, 443] -
@4c74356b41 从字符串更改为整数后仍然是同样的问题。
-
我必须将destinationAddressPrefix 更改为destinationAddressPrefixes 吗?
-
不,你不知道。显示真正的错误
-
它现在可以将端口用作字符串和整数。安全规则的名称存在问题。
标签: azure arm-template network-security-groups