json - Azure Policy:标记定义资源是否可以移动/部署到特定位置
问题描述
我试图根据 Azure 策略的标记(标记名称为“测试”且标记值为“是”)来阻止资源创建/迁移到特定区域之外的其他区域。到现在为止我得到了这个,但是当我分配它时,当新资源具有特定标签时,仍然可以在其他位置创建资源。此外,Azure 告诉我 if “需要一个来源并且存在”。有什么想法有什么问题吗?
{
"mode": "Indexed",
"policyRule": {
"if": {
"AllOf": [
{
"field": "tags['test']",
"exists": "true"
},
{
"value": "tags['test']",
"equals": "yes"
},
{
"field": "location",
"notIn": [
"France Central",
"France South",
"North Europe",
"West Europe"
]
}
]
},
"then": {
"effect": "deny"
}
},
"parameters": {}
}
谢谢!
解决方案
看起来我找到了答案:
{
"if": {
"AllOf": [
{
"field": "tags['test']",
"exists": "true"
},
{
"field": "tags['test']",
"equals": "yes"
},
{
"field": "location",
"notIn": [
"France Central",
"France South",
"North Europe",
"West Europe"
]
}
]
},
"then": {
"effect": "deny"
}
}
基本上,“值”字必须是“字段”字。
推荐阅读
- java - 如何使用 Apache POI 设置数据透视数据字段的数字格式?
- ios - Xamarin iOS 如何检查位置服务是否已关闭或应用级设备位置是否已关闭
- java - 无法为 Java 使用 JBMC(有界模型检查器)命令
- android - 我在签名时似乎无法构建我的 android 应用程序
- javascript - 使用输入字段创建名称列表以添加名称
- laravel - Laravel 中的 Cron 作业问题(任务计划)
- laravel - 调用未定义的方法 Illuminate\Database\Query\Builder::toArray()
- java - 使用滑动加载图像发生 InflateException
- java - 无法在环形图中显示中心文本
- nativescript - Nativescript Vue 核心模块