Bylaw

Gallery › Security Center › Azure built-in policies

Microsoft Defender for Containers should be enabled

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0

Microsoft Defender for Containers provides hardening, vulnerability assessment and run-time protections for your Azure, hybrid, and multi-cloud Kubernetes environments.

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

Azure Policy JSONASC_EnableAdvancedThreatProtectionOnContainers_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Microsoft Defender for Containers should be enabled",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Microsoft Defender for Containers provides hardening, vulnerability assessment and run-time protections for your Azure, hybrid, and multi-cloud Kubernetes environments.",
    "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.Resources/subscriptions"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/pricings",
          "name": "Containers",
          "existenceScope": "subscription",
          "existenceCondition": {
            "field": "Microsoft.Security/pricings/pricingTier",
            "equals": "Standard"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/1c988dd6-ade4-430f-a608-2a3e5b0a6d38",
  "name": "1c988dd6-ade4-430f-a608-2a3e5b0a6d38"
}
Bylaw1c988dd6-ade4-430f-a608-2a3e5b0a6d38.bylaw.ps1 · 28 lines
# Converted from ASC_EnableAdvancedThreatProtectionOnContainers_Audit.json by ConvertTo-Bylaw.
Policy '1c988dd6-ade4-430f-a608-2a3e5b0a6d38' {

    Properties @{
        DisplayName   = 'Microsoft Defender for Containers should be enabled'
        Description   = 'Microsoft Defender for Containers provides hardening, vulnerability assessment and run-time protections for your Azure, hybrid, and multi-cloud Kubernetes environments.'
        Version       = '1.0.0'
        Category      = 'Security Center'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Resources/subscriptions'

    AuditIfNotExists 'Microsoft.Security/pricings' -Name 'Containers' -ExistenceScope Subscription -Effect (Param Effect) {
        Require 'pricingTier is Standard' {
            Field pricingTier | Must -Be 'Standard'
        }
    }
}

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