【发布时间】:2019-02-26 10:41:51
【问题描述】:
我正在尝试创建一个 Azure 策略,该策略将使用“CanNotDelete”级别的资源锁部署到订阅中的资源组。
目前该策略 100% 符合,但该策略尚未创建任何锁。
我的 JSON policy.rules 文件中有以下内容;
{
"if": {
"field": "type",
"equals": "Microsoft.Resources/resourceGroups"
},
"then": {
"effect": "deployIfNotExists",
"details": {
"type": "Microsoft.Authorization/locks",
"existenceCondition": {
"field": "Microsoft.Authorization/locks/level",
"equals": "CanNotDelete"
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/0000-0000-0000-0000-0000000"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Authorization/locks",
"apiVersion": "2017-04-01",
"name": "ResourceLock",
"properties": {
"level": "CanNotDelete",
"notes": "Prevent accidental deletion of resource groups"
}
}
]
}
}
}
}
}
}
【问题讨论】:
-
您的 API 版本是否正确?所有与锁相关的文档我只能看到 2016-09-01
-
嘿@RahulRuikar api 版本是正确的,这可以通过资源浏览器\providers 找到。
标签: azure azure-resource-group