Bylaw

Gallery › Synapse › Azure built-in policies

Auditing on Synapse workspace should be enabled

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Auditing on your Synapse workspace should be enabled to track database activities across all databases on the dedicated SQL pools and save them in an audit log.

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

Azure Policy JSONWorkspaceSqlAuditing_Audit.json · 60 lines
{
  "properties": {
    "displayName": "Auditing on Synapse workspace should be enabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Auditing on your Synapse workspace should be enabled to track database activities across all databases on the dedicated SQL pools and save them in an audit log.",
    "metadata": {
      "version": "1.0.0",
      "category": "Synapse"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      },
      "setting": {
        "type": "String",
        "metadata": {
          "displayName": "Desired Auditing setting"
        },
        "defaultValue": "enabled",
        "allowedValues": [
          "enabled",
          "disabled"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Synapse/workspaces"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Synapse/workspaces/auditingSettings",
          "name": "default",
          "existenceCondition": {
            "field": "Microsoft.Synapse/workspaces/auditingSettings/state",
            "equals": "[parameters('setting')]"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e04e5000-cd89-451d-bb21-a14d24ff9c73",
  "name": "e04e5000-cd89-451d-bb21-a14d24ff9c73"
}
Bylawe04e5000-cd89-451d-bb21-a14d24ff9c73.bylaw.ps1 · 33 lines
# Converted from WorkspaceSqlAuditing_Audit.json by ConvertTo-Bylaw.
Policy 'e04e5000-cd89-451d-bb21-a14d24ff9c73' {

    Properties @{
        DisplayName   = 'Auditing on Synapse workspace should be enabled'
        Description   = 'Auditing on your Synapse workspace should be enabled to track database activities across all databases on the dedicated SQL pools and save them in an audit log.'
        Version       = '1.0.0'
        Category      = 'Synapse'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter Setting @{
        AllowedValues = @('enabled', 'disabled')
        Default       = 'enabled'
        DisplayName   = 'Desired Auditing setting'
    }

    Resource 'Microsoft.Synapse/workspaces'

    AuditIfNotExists 'Microsoft.Synapse/workspaces/auditingSettings' -Name 'default' -Effect (Param Effect) {
        Require 'state is the Setting parameter' {
            Field state | Must -Be (Param Setting)
        }
    }
}

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