Bylaw

Gallery › App Service › Azure built-in policies

[Deprecated]: [Deprecated]: Audit enabling of diagnostic logs in App Services

Converted Policy Audit Disabled Mode All Version 1.0.0-deprecated Deprecated

Audit enabling of diagnostic logs on the app. This enables you to recreate activity trails for investigation purposes if a security incident occurs or your network is compromised

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

Azure Policy JSONAuditLoggingMonitoring_Audit_Deprecated.json · 66 lines
{
  "properties": {
    "displayName": "[Deprecated]: [Deprecated]: Audit enabling of diagnostic logs in App Services",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Audit enabling of diagnostic logs on the app. This enables you to recreate activity trails for investigation purposes if a security incident occurs or your network is compromised",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "App Service",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites/config"
          },
          {
            "field": "name",
            "equals": "web"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Web/sites/config/detailedErrorLoggingEnabled",
                "notEquals": "true"
              },
              {
                "field": "Microsoft.Web/sites/config/httpLoggingEnabled",
                "notEquals": "true"
              },
              {
                "field": "Microsoft.Web/sites/config/requestTracingEnabled",
                "notEquals": "true"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/752c6934-9bcc-4749-b004-655e676ae2ac",
  "name": "752c6934-9bcc-4749-b004-655e676ae2ac"
}
Bylaw752c6934-9bcc-4749-b004-655e676ae2ac.bylaw.ps1 · 42 lines
# Converted from AuditLoggingMonitoring_Audit_Deprecated.json by ConvertTo-Bylaw.
Policy '752c6934-9bcc-4749-b004-655e676ae2ac' {

    Properties @{
        DisplayName   = '[Deprecated]: [Deprecated]: Audit enabling of diagnostic logs in App Services'
        Description   = 'Audit enabling of diagnostic logs on the app. This enables you to recreate activity trails for investigation purposes if a security incident occurs or your network is compromised'
        Version       = '1.0.0-deprecated'
        Category      = 'App Service'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Web/sites/config' {

        When {
            Field name | Must -Be 'web'
        }

        Require 'detailedErrorLoggingEnabled is true' {
            Field detailedErrorLoggingEnabled | Must -Be 'true'
        }

        Require 'httpLoggingEnabled is true' {
            Field httpLoggingEnabled | Must -Be 'true'
        }

        Require 'requestTracingEnabled is true' {
            Field requestTracingEnabled | Must -Be 'true'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/App Service/AuditLoggingMonitoring_Audit_Deprecated.json in Azure/azure-policy, under the MIT licence.