azure 自定义策略的别名

问题描述 投票:0回答:1

提供程序“Microsoft.Sql”和资源类型“服务器/数据库”下支持的别名是什么,用于创建天蓝色策略来审核pitr和ltr

我尝试了以下

{
  "properties": {
    "displayName": "Meijer PITR & LTR for SQL DB",
    "policyType": "Custom",
    "mode": "Indexed",
    "description": "Audit the SQL databases in POC for correct PITR and backup settings",
    "metadata": {
      "category": "SQL"
    },
    "version": "1.0.0",
    "parameters": {
      "pitrRetentionDays": {
        "type": "String",
        "metadata": {
          "displayName": "PITR retention",
          "description": "The number of days to retain the point-in-time recovery."
        },
        "defaultValue": "15 days"
      },
      "differentialRetentionHours": {
        "type": "String",
        "metadata": {
          "displayName": "Differential backup frequency",
          "description": "The number of hours to retain backups with 12-hour differentials."
        },
        "defaultValue": "12 hours"
      },
      "weeklyBackupWeeks": {
        "type": "String",
        "metadata": {
          "displayName": "Weekly LTR",
          "description": "The number of weeks to retain weekly backups."
        },
        "defaultValue": "3 weeks"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Sql/servers/databases"
          },
          {
            "field": "type",
            "equals": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicy"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Sql/servers/databases/restorePointInTime",
                "notEquals": "[parameters('pitrRetentionDays')]"
              },
              {
                "field": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicy/dailyRetention",
                "notEquals": "[parameters('differentialRetentionHours')]"
              },
              {
                "field": "Microsoft.Sql/servers/databases/backupLongTermRetentionPolicy/weeklyRetention",
                "notEquals": "[parameters('weeklyBackupWeeks')]"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "audit"
      }
    },
    "versions": [
      "1.0.0"
    ]
  }
}


azure-policy sqldb pitr ltr
1个回答
0
投票

提供程序“Microsoft.Sql”和资源类型“服务器/数据库”下支持的别名是什么,用于创建天蓝色策略来审计pitr和ltr。

以下是

Microsoft.Sql/servers/databases
支持的资源类型,用于创建用于审核
PITR
LTR
的 Azure 策略。

enter image description here

资源字段类型 dailyRetentionbackupLongTermRetentionPolicy 资源类型中不可用。

政策错误:

enter image description here

对于上述支持的类型,您可以使用 backupShortTermRetentionPolicies 代替 backupLongTermRetentionPolicy

这是审核

PITR
Ltr
的更新政策。

    {
      "mode": "Indexed",
      "policyRule": {
        "if": {
          "allOf": [
            {
              "field": "type",
              "equals": "Microsoft.Sql/servers/databases/backupShortTermRetentionPolicies"
            },
            {
              "anyOf": [
                {
                  "field": "Microsoft.Sql/servers/databases/restorePointInTime",
                  "notEquals": "[parameters('pitrRetentionDays')]"
                },
                {
                  "field": "Microsoft.Sql/servers/databases/backupShortTermRetentionPolicies/retentionDays",
                  "notEquals": "[parameters('rentalDays')]"
                },
                {
                  "field": "Microsoft.Sql/servers/databases/backupShortTermRetentionPolicies/default.diffBackupIntervalInHours",
                  "notEquals": "[parameters('internalInHours')]"
                }
              ]
            }
          ]
        },
        "then": {
          "effect": "audit"
        }
      },
      "parameters": {
        "rentalDays": {
          "type": "String",
          "metadata": {
            "displayName": "PITR retention",
            "description": "The number of days to retain the point-in-time recovery."
          },
          "defaultValue": "15 days"
        },
        "pitrRetentionDays": {
          "type": "String",
          "metadata": {
            "displayName": "PITR retention",
            "description": "The number of days to retain the point-in-time recovery."
          },
          "defaultValue": "30 days"
        },
        "internalInHours": {
          "type": "String",
          "metadata": {
            "displayName": "Weekly LTR",
            "description": "The number of weeks to retain weekly backups."
          },
          "defaultValue": "12 hours"
        }
      }
    }

策略已成功创建并分配了所需的参数。

enter image description here

参考: 如何使用 PITR 保留期审计 SQL DB

© www.soinside.com 2019 - 2024. All rights reserved.