azure - 适用于 Linux 和 Windows 计算机的 Azure 标记策略
问题描述
有一个 ARM 策略用于检查 Azure 中任何 VM 上是否存在特定标签:
{
"mode": "Indexed",
"policyRule": {
"if": {
"AllOf": [
{
"field": "type",
"in": [
"microsoft.compute/virtualmachines",
"Microsoft.ClassicCompute/virtualMachines"
]
},
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "false"
}
]
},
"then": {
"effect": "audit"
}
},
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"displayName": "tagName",
"description": "Tag used to unequally identify a VM"
}
}
}
}
问题:
如何创建一个单独的策略,一个用于 Linux,另一个用于 Windows VM?我找不到如何过滤的方法。即对于 Windows,我使用此策略脚本:
{
"mode": "Indexed",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"field": "Microsoft.Compute/imagePublisher",
"in": [
"MicrosoftWindowsServer",
"MicrosoftSQLServer"
]
},
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "false"
}
]
},
"then": {
"effect": "audit"
}
},
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"displayName": "tagName",
"description": "Tag used to help unequally identify a VM"
}
}
}
}
但上面同时显示了 Windows 和 Linux,因为它的逻辑类似于“如果 VM 是 windows 并且具有特定标签,则表示兼容;否则如果没有特定标签或 VM 是 Linux,则视为不兼容”。
需求:
1x 策略查看只有多少 Windows VM 符合要求(根据标签)。
1x 策略查看只有多少 Linux VM 符合要求(根据标签)。
解决方案
尝试使用 Microsoft.Compute/virtualMachines/imagePublisher 而不是 Microsoft.Compute/imagePublisher
推荐阅读
- codeigniter - 动态菜单/为菜单创建控制器?
- python - Better way to file response with DRF?
- php - How to parse nslookup result by regex
- r - 当我在 R 中转换为日期格式时,日期会提前 2 天
- java - 由@JsonIdentityInfo 序列化的对象的反序列化
- nginx - 多个站点的 nginx 配置一个 ip 地址和一个服务器
- javascript - Babel 7 (webpack) 转换为大多数向后兼容的代码
- ios - 下标数组改变坐标
- python - 在 Pandas 中混合 DataFrame
- sql - 来自不同表的列的总和