Bylaw

Gallery › Security Center › Azure built-in policies

Configure basic Microsoft Defender for Storage to be enabled (Activity Monitoring only)

Converted Policy DeployIfNotExists Disabled Mode All Version 3.0.0

Microsoft Defender for Storage provides Azure-native threat detection for storage accounts. This policy enables basic features (Activity Monitoring). For full protection, including Malware Scanning and Sensitive Data Discovery, use aka.ms/DFStoragePolicy. Major version update: PerTransaction is no longer supported for new enablements after Feb 5, 2025. Existing accounts using it remain supported. Learn more: aka.ms/DF-Storage/NewPlanMigration.

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

Azure Policy JSONMDC_Microsoft_Defender_For_Storage_Basic_DINE.json · 119 lines
{
  "properties": {
    "displayName": "Configure basic Microsoft Defender for Storage to be enabled (Activity Monitoring only)",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Microsoft Defender for Storage provides Azure-native threat detection for storage accounts. This policy enables basic features (Activity Monitoring). For full protection, including Malware Scanning and Sensitive Data Discovery, use aka.ms/DFStoragePolicy. Major version update: PerTransaction is no longer supported for new enablements after Feb 5, 2025. Existing accounts using it remain supported. Learn more: aka.ms/DF-Storage/NewPlanMigration.",
    "version": "3.0.0",
    "metadata": {
      "version": "3.0.0",
      "category": "Security Center"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "defaultValue": "DeployIfNotExists"
      },
      "subPlan": {
        "type": "String",
        "metadata": {
          "displayName": "Storage bundle's sub plan",
          "description": "Sets the sub plan for Storage bundle"
        },
        "allowedValues": [
          "DefenderForStorageV2"
        ],
        "defaultValue": "DefenderForStorageV2"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Resources/subscriptions"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/pricings",
          "name": "StorageAccounts",
          "deploymentScope": "subscription",
          "existenceScope": "subscription",
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
          ],
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Security/pricings/pricingTier",
                "equals": "Standard"
              },
              {
                "field": "Microsoft.Security/pricings/subPlan",
                "equals": "[parameters('subPlan')]"
              }
            ]
          },
          "deployment": {
            "location": "westeurope",
            "properties": {
              "mode": "incremental",
              "parameters": {
                "subPlan": {
                  "value": "[parameters('subPlan')]"
                }
              },
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "subPlan": {
                    "type": "String"
                  }
                },
                "variables": {},
                "resources": [
                  {
                    "type": "Microsoft.Security/pricings",
                    "apiVersion": "2023-01-01",
                    "name": "StorageAccounts",
                    "properties": {
                      "subPlan": "[parameters('subPlan')]",
                      "pricingTier": "Standard",
                      "extensions": [
                        {
                          "name": "OnUploadMalwareScanning",
                          "isEnabled": "False"
                        },
                        {
                          "name": "SensitiveDataDiscovery",
                          "isEnabled": "False"
                        }
                      ]
                    }
                  }
                ],
                "outputs": {}
              }
            }
          }
        }
      }
    },
    "versions": [
      "3.0.0",
      "2.0.0",
      "1.1.0",
      "1.0.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/17bc14a7-92e1-4551-8b8c-80f36953e166",
  "name": "17bc14a7-92e1-4551-8b8c-80f36953e166"
}
Bylaw17bc14a7-92e1-4551-8b8c-80f36953e166.bylaw.ps1 · 42 lines
# Converted from MDC_Microsoft_Defender_For_Storage_Basic_DINE.json by ConvertTo-Bylaw.
Policy '17bc14a7-92e1-4551-8b8c-80f36953e166' {

    Properties @{
        DisplayName   = 'Configure basic Microsoft Defender for Storage to be enabled (Activity Monitoring only)'
        Description   = 'Microsoft Defender for Storage provides Azure-native threat detection for storage accounts. This policy enables basic features (Activity Monitoring). For full protection, including Malware Scanning and Sensitive Data Discovery, use aka.ms/DFStoragePolicy. Major version update: PerTransaction is no longer supported for new enablements after Feb 5, 2025. Existing accounts using it remain supported. Learn more: aka.ms/DF-Storage/NewPlanMigration.'
        Version       = '3.0.0'
        Category      = 'Security Center'
        PolicyVersion = '3.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'DeployIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter SubPlan @{
        AllowedValues = @('DefenderForStorageV2')
        Default       = 'DefenderForStorageV2'
        DisplayName   = 'Storage bundle''s sub plan'
        Description   = 'Sets the sub plan for Storage bundle'
    }

    Resource 'Microsoft.Resources/subscriptions'

    DeployIfNotExists 'Microsoft.Security/pricings' -Role 'Security Admin' -Name 'StorageAccounts' -ExistenceScope Subscription -Effect (Param Effect) {
        Require 'pricingTier is Standard and subPlan is the SubPlan parameter' {
            Field pricingTier | Must -Be 'Standard'
            Field subPlan | Must -Be (Param SubPlan)
        }
        Deployment @{
            TemplateFile = './templates/17bc14a7-92e1-4551-8b8c-80f36953e166.json'
            Scope        = 'Subscription'
            Location     = 'westeurope'
            Parameters   = [ordered]@{
                subPlan = (Param SubPlan)
            }
        }
    }
}

Its deployment templates are written beside it:

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