【发布时间】:2021-08-16 20:30:19
【问题描述】:
关于我正在创建的 Azure 策略,我在这里做错了一些事情。尝试创建一个命名策略来阻止创建不匹配的资源(在本例中为资源组)。
{
"properties": {
"mode": "All",
"displayName": "Company Naming Convention - Resource Groups",
"description": "This policy governs the naming standard for resource groups and should be assigned at the resource group scope. The naming scheme is rg-region-workload name-environment-optional instance number'.",
"metadata": {
"category": "Governance"
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/resourceGroups"
},
{
"allOf": [
{
"field": "name",
"notLike": "rg-useast-*"
},
{
"field": "name",
"notLike": "rg-useast2-*"
},
{
"field": "name",
"notLike": "rg-uscentral-*"
},
{
"field": "name",
"notLike": "rg-uksouth-*"
}
]
},
{
"allOf": [
{
"field": "name",
"notLike": "*-production.###"
},
{
"field": "name",
"notLike": "*-development.###"
},
{
"field": "name",
"notLike": "*-qualityassurance.###"
},
{
"field": "name",
"notLike": "*-testing.###"
}
]
}
]
},
"then": {
"effect": "deny"
}
}
}
}
我还想创建一个策略来审核与此名称不匹配的现有资源,但我可以稍后解决这个问题。有人建议我做错了什么或更好的解决方法吗?
【问题讨论】:
-
那么当您实施此政策时会发生什么?它不会阻止创建命名错误的资源组吗?
-
不,恐怕不会。我之前测试时完全没有做任何事情。
标签: json azure azure-policy