Bylaw

Gallery › Security Center › Azure built-in policies

Microsoft Defender for Azure Cosmos DB should be enabled

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0

Microsoft Defender for Azure Cosmos DB is an Azure-native layer of security that detects attempts to exploit databases in your Azure Cosmos DB accounts.
Defender for Azure Cosmos DB detects potential SQL injections, known bad actors based on Microsoft Threat Intelligence, suspicious access patterns, and potential exploitations of your database through compromised identities or malicious insiders.

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

Azure Policy JSONMDC_Microsoft_Defender_Azure_Cosmos_DB_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Microsoft Defender for Azure Cosmos DB should be enabled",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Microsoft Defender for Azure Cosmos DB is an Azure-native layer of security that detects attempts to exploit databases in your Azure Cosmos DB accounts.\nDefender for Azure Cosmos DB detects potential SQL injections, known bad actors based on Microsoft Threat Intelligence, suspicious access patterns, and potential exploitations of your database through compromised identities or malicious insiders.",
    "metadata": {
      "version": "1.0.0",
      "category": "Security Center"
    },
    "version": "1.0.0",
    "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.Resources/subscriptions"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/pricings",
          "name": "CosmosDbs",
          "existenceScope": "subscription",
          "existenceCondition": {
            "field": "Microsoft.Security/pricings/pricingTier",
            "equals": "Standard"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/adbe85b5-83e6-4350-ab58-bf3a4f736e5e",
  "name": "adbe85b5-83e6-4350-ab58-bf3a4f736e5e"
}
Bylawadbe85b5-83e6-4350-ab58-bf3a4f736e5e.bylaw.ps1 · 28 lines
# Converted from MDC_Microsoft_Defender_Azure_Cosmos_DB_Audit.json by ConvertTo-Bylaw.
Policy 'adbe85b5-83e6-4350-ab58-bf3a4f736e5e' {

    Properties @{
        DisplayName   = 'Microsoft Defender for Azure Cosmos DB should be enabled'
        Description   = 'Microsoft Defender for Azure Cosmos DB is an Azure-native layer of security that detects attempts to exploit databases in your Azure Cosmos DB accounts.
Defender for Azure Cosmos DB detects potential SQL injections, known bad actors based on Microsoft Threat Intelligence, suspicious access patterns, and potential exploitations of your database through compromised identities or malicious insiders.'
        Version       = '1.0.0'
        Category      = 'Security Center'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        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 'CosmosDbs' -ExistenceScope Subscription -Effect (Param Effect) {
        Require 'pricingTier is Standard' {
            Field pricingTier | Must -Be 'Standard'
        }
    }
}

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