json - 如何在 Azure 策略中强制执行标记值模式?
问题描述
我想为资源组所需的标签强制执行标签值模式“RJGVM-###”。我设法使它成为必需,但每当我输入任何值时,它仍然通过。
{
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"not": {
"field": "[concat('tags[',parameters('tagName'), ']')]",
"exists": "true"
}
},
{
"value": "[resourceGroup().tags[parameters('tagName')]]",
"notMatch": "RJGVM-###"
}
]
},
"then": {
"effect": "deny"
}
},
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"displayName": "Tag Name",
"description": "Name of the tag, such as 'environment'"
}
}
}
}
解决方案
请参考以下链接中提到的此示例,以确保标签值上的匹配模式:
https://github.com/Azure/azure-policy/tree/master/samples/TextPatterns/enforce-tag-match-pattern
推荐阅读
- reactjs - 如何在 redux 操作完成并更新 redux 存储后触发回调?
- ios - Appkit 在 venv 中正常工作,但不能不使用虚拟 env
- postgresql - pgadmin 只为超过 225000 行的表上的查询返回 1000 行
- vue.js - 在 Vuetify 数据表列上应用自定义类
- c# - 不能在 C# 中一起“添加”粗体和斜体
- python - 如何在python中计算ndarray持有Fraction类型变量的倒数?
- ios - 作为 IBOutlet 连接的 UITableView 的自定义初始化
- excel - 合并来自匹配值的特定数据
- ios - React Native - Bridge iOS 单元测试
- python - Python:在特定对角线上查找像素