Bylaw

Gallery › Synapse › Azure built-in policies

Synapse workspaces with SQL auditing to storage account destination should be configured with 90 days retention or higher

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 2.0.0

For incident investigation purposes, we recommend setting the data retention for your Synapse workspace' SQL auditing to storage account destination to at least 90 days. Confirm that you are meeting the necessary retention rules for the regions in which you are operating. This is sometimes required for compliance with regulatory standards.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONWorkspaceSqlAuditingRetentionDays_Audit.json · 69 lines
{
  "properties": {
    "displayName": "Synapse workspaces with SQL auditing to storage account destination should be configured with 90 days retention or higher",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "For incident investigation purposes, we recommend setting the data retention for your Synapse workspace' SQL auditing to storage account destination to at least 90 days. Confirm that you are meeting the necessary retention rules for the regions in which you are operating. This is sometimes required for compliance with regulatory standards.",
    "metadata": {
      "version": "2.0.0",
      "category": "Synapse"
    },
    "version": "2.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Synapse/workspaces"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Synapse/workspaces/auditingSettings",
          "name": "default",
          "existenceCondition": {
            "anyOf": [
              {
                "allOf": [
                  {
                    "field": "Microsoft.Synapse/workspaces/auditingSettings/isAzureMonitorTargetEnabled",
                    "equals": true
                  },
                  {
                    "field": "Microsoft.Synapse/workspaces/auditingSettings/storageEndpoint",
                    "equals": ""
                  }
                ]
              },
              {
                "field": "Microsoft.Synapse/workspaces/auditingSettings/retentionDays",
                "equals": 0
              },
              {
                "field": "Microsoft.Synapse/workspaces/auditingSettings/retentionDays",
                "greaterOrEquals": 90
              }
            ]
          }
        }
      }
    },
    "versions": [
      "2.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/529ea018-6afc-4ed4-95bd-7c9ee47b00bc",
  "name": "529ea018-6afc-4ed4-95bd-7c9ee47b00bc"
}
Bylaw529ea018-6afc-4ed4-95bd-7c9ee47b00bc.bylaw.ps1 · 34 lines
# Converted from WorkspaceSqlAuditingRetentionDays_Audit.json by ConvertTo-Bylaw.
Policy '529ea018-6afc-4ed4-95bd-7c9ee47b00bc' {

    Properties @{
        DisplayName   = 'Synapse workspaces with SQL auditing to storage account destination should be configured with 90 days retention or higher'
        Description   = 'For incident investigation purposes, we recommend setting the data retention for your Synapse workspace'' SQL auditing to storage account destination to at least 90 days. Confirm that you are meeting the necessary retention rules for the regions in which you are operating. This is sometimes required for compliance with regulatory standards.'
        Version       = '2.0.0'
        Category      = 'Synapse'
        PolicyVersion = '2.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Synapse/workspaces'

    AuditIfNotExists 'Microsoft.Synapse/workspaces/auditingSettings' -Name 'default' -Effect (Param Effect) {
        Require 'isAzureMonitorTargetEnabled, storageEndpoint and retentionDays are as required' {
            AnyOf {
                AllOf {
                    Field isAzureMonitorTargetEnabled | Must -Be $true
                    Field storageEndpoint | Must -Be ''
                }
                Field retentionDays | Must -Be 0
                Field retentionDays | Must -BeGreaterOrEqual 90 -IfPresent
            }
        }
    }
}

Source: built-in-policies/policyDefinitions/Synapse/WorkspaceSqlAuditingRetentionDays_Audit.json in Azure/azure-policy, under the MIT licence.