Bylaw

Gallery › SQL › Azure built-in policies

[Deprecated]: Email notifications to admins should be enabled in SQL server advanced data security settings

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-deprecated Deprecated

Audit that 'email notification to admins and subscription owners' is enabled in the SQL server advanced threat protection settings. This ensures that any detections of anomalous activities on SQL server are reported as soon as possible to the admins.

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

Azure Policy JSONSqlServer_AdvancedDataSecurityEmailAdmins_Audit.json · 50 lines
{
  "properties": {
    "displayName": "[Deprecated]: Email notifications to admins should be enabled in SQL server advanced data security settings",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Audit that 'email notification to admins and subscription owners' is enabled in the SQL server advanced threat protection settings. This ensures that any detections of anomalous activities on SQL server are reported as soon as possible to the admins.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "SQL",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Disabled",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Sql/servers"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Sql/servers/securityAlertPolicies",
          "name": "default",
          "existenceCondition": {
            "field": "Microsoft.Sql/servers/securityAlertPolicies/emailAccountAdmins",
            "equals": "true"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/c8343d2f-fdc9-4a97-b76f-fc71d1163bfc",
  "name": "c8343d2f-fdc9-4a97-b76f-fc71d1163bfc"
}
Bylawc8343d2f-fdc9-4a97-b76f-fc71d1163bfc.bylaw.ps1 · 28 lines
# Converted from SqlServer_AdvancedDataSecurityEmailAdmins_Audit.json by ConvertTo-Bylaw.
Policy 'c8343d2f-fdc9-4a97-b76f-fc71d1163bfc' {

    Properties @{
        DisplayName   = '[Deprecated]: Email notifications to admins should be enabled in SQL server advanced data security settings'
        Description   = 'Audit that ''email notification to admins and subscription owners'' is enabled in the SQL server advanced threat protection settings. This ensures that any detections of anomalous activities on SQL server are reported as soon as possible to the admins.'
        Version       = '1.0.0-deprecated'
        Category      = 'SQL'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Sql/servers'

    AuditIfNotExists 'Microsoft.Sql/servers/securityAlertPolicies' -Name 'default' -Effect (Param Effect) {
        Require 'emailAccountAdmins is true' {
            Field emailAccountAdmins | Must -Be 'true'
        }
    }
}

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