Bylaw

Gallery › Security Center › Azure built-in policies

Azure Defender for SQL should be enabled for unprotected MySQL flexible servers

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Audit MySQL flexible servers without Advanced Data Security

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

Azure Policy JSONMySQL_FlexibleServers_DefenderForSQL_Audit.json · 49 lines
{
  "properties": {
    "displayName": "Azure Defender for SQL should be enabled for unprotected MySQL flexible servers",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Audit MySQL flexible servers without Advanced Data Security",
    "metadata": {
      "version": "1.0.0",
      "category": "Security Center"
    },
    "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"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.DBforMySQL/flexibleservers"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.DBforMySQL/flexibleservers/advancedThreatProtectionSettings",
          "name": "Default",
          "existenceCondition": {
            "field": "Microsoft.DBforMySQL/flexibleServers/advancedThreatProtectionSettings/state",
            "equals": "Enabled"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/3bc8a0d5-38e0-4a3d-a657-2cb64468fc34",
  "name": "3bc8a0d5-38e0-4a3d-a657-2cb64468fc34"
}
Bylaw3bc8a0d5-38e0-4a3d-a657-2cb64468fc34.bylaw.ps1 · 28 lines
# Converted from MySQL_FlexibleServers_DefenderForSQL_Audit.json by ConvertTo-Bylaw.
Policy '3bc8a0d5-38e0-4a3d-a657-2cb64468fc34' {

    Properties @{
        DisplayName   = 'Azure Defender for SQL should be enabled for unprotected MySQL flexible servers'
        Description   = 'Audit MySQL flexible servers without Advanced Data Security'
        Version       = '1.0.0'
        Category      = 'Security Center'
        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'
    }

    Resource 'Microsoft.DBforMySQL/flexibleservers'

    AuditIfNotExists 'Microsoft.DBforMySQL/flexibleservers/advancedThreatProtectionSettings' -Name 'Default' -Effect (Param Effect) {
        Require 'state is Enabled' {
            Field state | Must -Be 'Enabled'
        }
    }
}

Source: built-in-policies/policyDefinitions/Security Center/MySQL_FlexibleServers_DefenderForSQL_Audit.json in Azure/azure-policy, under the MIT licence.