Bylaw

Gallery › Storage › Azure built-in policies

[Deprecated]: Deploy Defender for Storage (Classic) on storage accounts

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.1.0-deprecated Deprecated

This policy enables Defender for Storage (Classic) on storage accounts - This policy is deprecated. New enablements of the classic plan are no longer supported, effective February 5, 2025. Existing subscriptions and storage accounts already enabled with the classic plan can continue to use it. For more details, please refer to https://aka.ms/DF-Storage/NewPlanMigration.

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

Azure Policy JSONStorageAdvancedThreatProtection_DINE.json · 83 lines
{
  "properties": {
    "displayName": "[Deprecated]: Deploy Defender for Storage (Classic) on storage accounts",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy enables Defender for Storage (Classic) on storage accounts - This policy is deprecated. New enablements of the classic plan are no longer supported, effective February 5, 2025. Existing subscriptions and storage accounts already enabled with the classic plan can continue to use it. For more details, please refer to https://aka.ms/DF-Storage/NewPlanMigration.",
    "metadata": {
      "version": "1.1.0-deprecated",
      "category": "Storage",
      "deprecated": true
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Storage/storageAccounts"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/advancedThreatProtectionSettings",
          "name": "current",
          "existenceCondition": {
            "field": "Microsoft.Security/advancedThreatProtectionSettings/isEnabled",
            "equals": "true"
          },
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/fb1c8493-542b-48eb-b624-b4c8fea62acd"
          ],
          "deployment": {
            "properties": {
              "mode": "incremental",
              "template": {
                "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "storageAccountName": {
                    "type": "string"
                  }
                },
                "resources": [
                  {
                    "apiVersion": "2019-01-01",
                    "type": "Microsoft.Storage/storageAccounts/providers/advancedThreatProtectionSettings",
                    "name": "[concat(parameters('storageAccountName'), '/Microsoft.Security/current')]",
                    "properties": {
                      "isEnabled": true
                    }
                  }
                ]
              },
              "parameters": {
                "storageAccountName": {
                  "value": "[field('name')]"
                }
              }
            }
          }
        }
      }
    },
    "versions": [
      "1.1.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/361c2074-3595-4e5d-8cab-4f21dffc835c",
  "name": "361c2074-3595-4e5d-8cab-4f21dffc835c"
}
Bylaw361c2074-3595-4e5d-8cab-4f21dffc835c.bylaw.ps1 · 32 lines
# Converted from StorageAdvancedThreatProtection_DINE.json by ConvertTo-Bylaw.
Policy '361c2074-3595-4e5d-8cab-4f21dffc835c' {

    Properties @{
        DisplayName   = '[Deprecated]: Deploy Defender for Storage (Classic) on storage accounts'
        Description   = 'This policy enables Defender for Storage (Classic) on storage accounts - This policy is deprecated. New enablements of the classic plan are no longer supported, effective February 5, 2025. Existing subscriptions and storage accounts already enabled with the classic plan can continue to use it. For more details, please refer to https://aka.ms/DF-Storage/NewPlanMigration.'
        Version       = '1.1.0-deprecated'
        Category      = 'Storage'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Storage/storageAccounts'

    DeployIfNotExists 'Microsoft.Security/advancedThreatProtectionSettings' -Role 'Security Admin' -Name 'current' -Effect (Param Effect) {
        Require 'isEnabled is true' {
            Field isEnabled | Must -Be 'true'
        }
        Deployment -TemplateFile './templates/361c2074-3595-4e5d-8cab-4f21dffc835c.json' -Parameters ([ordered]@{
                storageAccountName = (Arm '[field(''name'')]')
            })
    }
}

Its deployment templates are written beside it:

Source: built-in-policies/policyDefinitions/Storage/StorageAdvancedThreatProtection_DINE.json in Azure/azure-policy, under the MIT licence.