Bylaw

Gallery › Monitoring › Azure Community Policy

Deny creation of Log Analytics workspace without daily quota

Converted Policy Audit Deny Disabled Mode all Version 1.0.0

This policy denies the creation of Log Analytics workspaces if the daily quota is not set.

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

Azure Policy JSONazurepolicy.json · 45 lines
{
  "name": "a8da5dfa-4bb2-46aa-bd3f-5be6bcf2681b",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Deny creation of Log Analytics workspace without daily quota",
    "description": "This policy denies the creation of Log Analytics workspaces if the daily quota is not set.",
    "metadata": {
      "category": "Monitoring",
      "version": "1.0.0"
    },
    "mode": "all",
    "parameters": {
      "effect": {
        "type": "string",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Deny"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.OperationalInsights/workspaces"
          },
          {
            "field": "Microsoft.OperationalInsights/workspaces/workspaceCapping.dailyQuotaGb",
            "exists": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawa8da5dfa-4bb2-46aa-bd3f-5be6bcf2681b.bylaw.ps1 · 28 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'a8da5dfa-4bb2-46aa-bd3f-5be6bcf2681b' {

    Properties @{
        DisplayName = 'Deny creation of Log Analytics workspace without daily quota'
        Description = 'This policy denies the creation of Log Analytics workspaces if the daily quota is not set.'
        Category    = 'Monitoring'
        Version     = '1.0.0'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.OperationalInsights/workspaces' {

        Require 'workspaceCapping.dailyQuotaGb exists' {
            Field workspaceCapping.dailyQuotaGb | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Monitoring/log-analytics-workspace-require-daily-quota/azurepolicy.json in Azure/Community-Policy, under the MIT licence.