【发布时间】:2021-09-12 19:26:19
【问题描述】:
我对策略的arm部署非常困惑,希望有人可以帮助我解决这个问题。
我想制定一项政策,根据他们的 Sku.name 拒绝数据库部署。
是的,我想允许创建它们是 standard 或 Basic 的数据库,并拒绝所有其他 sku。
我有这个json 配置,但它只能部分工作。
{
"properties": {
"displayName": "Not allowed resource types",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy enables you to specify the resource types that your organization cannot deploy.",
"parameters": {
"listOfAllowedSKUs": {
"type": "Array",
"metadata": {
"description": "The list of resource types that cannot be deployed.",
"displayName": "Not allowed resource types",
"strongType": "resourceTypes"
}
}
},
"policyRule": {
"if": {
"field": "type",
"in": "[parameters('listOfAllowedSKUs')]"
},
"then": {
"effect": "Deny"
}
}
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/6c112d4e-5bc7-47ae-a041-ea2d9dccd749",
"type": "Microsoft.Authorization/policyDefinitions",
"name": "6c112d4e-5bc7-47ae-a041-ea2d9dccd749"
}
参数:
{
"listOfAllowedSKUs": {
"type": "Array",
"allowedValues": [
"Standard",
"Basic"
],
"metadata": {
"displayName": "Allowed SKUs",
"description": "The list of SKUs that can be specified for databases."
}
}
}
和规则:
{
"if": {
"not": {
"field": "Microsoft.Sql/servers/databases/sku.name",
"in": "[parameters('listOfAllowedSKUs')]"
}
},
"then": {
"effect": "deny"
}
}
当我部署此策略时,我只能部署基本 Sku,而所有其他(包括标准)都被拒绝。
如何允许同时创建 Basic 和 Standard?
非常感谢愿意花费宝贵时间帮助我理解这一点的人。
【问题讨论】:
-
您需要过滤
sku.tier。对于 basic,name 和 tier 是相同的,但是对于 standard,tier = standard 并且 name 可以是 S1、S2 等...... -
是的,我只是设法使用
Microsoft.Sql/servers/databases/sku.tier使它工作,我只能创建标准和基本。如果您想将其发布为答案,我将投票。只是一个基本问题,我在哪里可以找到资源的所有规范,例如Microsoft.Sql/servers/databases/sku.tier等?是否有我可以阅读的文档来了解我可以定位哪些子资源?
标签: azure azure-sql-database azure-resource-manager azure-policy azure-bicep