我执行了一项天蓝色的自定义策略,该策略发现我的订阅中的对象不符合要求,且缺少自定义标记。
我从这项政策中犯了很多错误,因为它还会发现oms代理,扩展名等。
这里是json:
{
"mode": "All",
"policyRule": {
"if": {
"anyOf": [
{
"field": "tags['TAG1']",
"exists": false
},
{
"field": "tags['TAG2']",
"exists": false
}
]
},
"then": {
"effect": "audit"
}
},
"parameters": {}
}
它搜索所有资源,如果没有该标签,则对其进行审核。
是否可以针对特定资源类型进行指定排除?例如Microsoft.Compute / virtualMachines / extensions等...
谢谢
答案 0 :(得分:1)
这样,您可以在“ notEquals”运算符中提及您不想为其检查标签的所有资源类型。
{
"if": {
"allOf": [
{
"field": "type",
"notEquals": "Microsoft.Security/assessments"
},
{
"field": "type",
"notEquals": "Microsoft.Compute/VirtualMachines"
},
{
"anyOf": [
{
"field": "tags['TAG1']",
"exists": false
},
{
"field": "tags['TAG2']",
"exists": false
}
]
}
]
},
"then": {
"effect": "audit"
}
}