Bylaw

Gallery › Monitoring › Azure built-in policies

Azure Front Door Standard or Premium (Plus WAF) should have resource logs enabled

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Enable Resource logs for Azure Front Door Standard or Premium (plus WAF) and stream to a Log Analytics workspace. Get detailed visibility into inbound web traffic and actions taken to mitigate attacks.

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

Azure Policy JSONAFDStandardOrPremiumShouldHaveResourceLogsEnabledPolicy.json · 60 lines
{
  "properties": {
    "displayName": "Azure Front Door Standard or Premium (Plus WAF) should have resource logs enabled",
    "policyType": "BuiltIn",
    "version": "1.0.0",
    "mode": "Indexed",
    "description": "Enable Resource logs for Azure Front Door Standard or Premium (plus WAF) and stream to a Log Analytics workspace. Get detailed visibility into inbound web traffic and actions taken to mitigate attacks.",
    "metadata": {
      "version": "1.0.0",
      "category": "Monitoring"
    },
    "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.Cdn/profiles"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Insights/diagnosticSettings",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Insights/diagnosticSettings/logs.enabled",
                "equals": "true"
              },
              {
                "field": "Microsoft.Insights/diagnosticSettings/metrics.enabled",
                "equals": "true"
              },
              {
                "field": "Microsoft.Insights/diagnosticSettings/workspaceId",
                "exists": "true"
              }
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/cd906338-3453-47ba-9334-2d654bf845af",
  "name": "cd906338-3453-47ba-9334-2d654bf845af"
}
Bylawcd906338-3453-47ba-9334-2d654bf845af.bylaw.ps1 · 29 lines
# Converted from AFDStandardOrPremiumShouldHaveResourceLogsEnabledPolicy.json by ConvertTo-Bylaw.
Policy 'cd906338-3453-47ba-9334-2d654bf845af' {

    Properties @{
        DisplayName   = 'Azure Front Door Standard or Premium (Plus WAF) should have resource logs enabled'
        Description   = 'Enable Resource logs for Azure Front Door Standard or Premium (plus WAF) and stream to a Log Analytics workspace. Get detailed visibility into inbound web traffic and actions taken to mitigate attacks.'
        Version       = '1.0.0'
        Category      = 'Monitoring'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Cdn/profiles'

    AuditIfNotExists 'Microsoft.Insights/diagnosticSettings' -Effect (Param Effect) {
        Require 'logs.enabled is true, metrics.enabled is true and workspaceId exists' {
            Field logs.enabled | Must -Be 'true'
            Field metrics.enabled | Must -Be 'true'
            Field workspaceId | Must -Exist
        }
    }
}

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