【发布时间】:2023-01-13 20:20:09
【问题描述】:
我创建此策略定义是为了拒绝在特定子网上分配公共 IP。目前我必须将策略分别分配给每个子网,但我正在寻找一种进入多个子网的方法。 (我按照this指南在整个 Vnet 上阻止公共 IP,但我有某些子网应该允许分配新的公共 IP)。
{
"mode": "Indexed",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/networkInterfaces"
},
{
"not": {
"field": "Microsoft.Network/networkInterfaces/ipconfigurations[*].publicIpAddress.id",
"notLike": "*"
}
},
{
"field": "Microsoft.Network/networkInterfaces/ipconfigurations[*].subnet.id",
"contains": "[parameters('subnetId')]"
}
]
},
"then": {
"effect": "deny"
}
},
"parameters": {
"subnetId": {
"type": "String",
"metadata": {
"displayName": "Subnet ID",
"description": "The resource ID of the virtual network subnet that should have a rule enabled. Example: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"
}
}
}
}
我尝试将类型设置为数组并在“[parameters('subnetId')]”上使用拆分函数,但我总是在 Azure 上遇到错误。
关于如何实现这一目标的任何想法?谢谢!
【问题讨论】:
标签: azure arm-template subnet azure-policy vnet