Bylaw

Gallery › Security Center › Azure built-in policies

[Deprecated]: Configure Microsoft Defender for Storage (Classic) to be enabled

Converted Policy DeployIfNotExists Disabled Mode All Version 1.1.0-deprecated Deprecated

Microsoft Defender for Storage (Classic) provides detections of unusual and potentially harmful attempts to access or exploit storage accounts - please note that deprecation is for commercial cloud only.

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

Azure Policy JSONASC_Azure_Defender_Storage_DINE.json · 84 lines
{
  "properties": {
    "displayName": "[Deprecated]: Configure Microsoft Defender for Storage (Classic) to be enabled",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Microsoft Defender for Storage (Classic) provides detections of unusual and potentially harmful attempts to access or exploit storage accounts - please note that deprecation is for commercial cloud only.",
    "metadata": {
      "version": "1.1.0-deprecated",
      "category": "Security Center",
      "deprecated": true
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "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": {
            "field": "Microsoft.Security/pricings/pricingTier",
            "equals": "Standard"
          },
          "deployment": {
            "location": "westeurope",
            "properties": {
              "mode": "incremental",
              "parameters": {},
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {},
                "variables": {},
                "resources": [
                  {
                    "type": "Microsoft.Security/pricings",
                    "apiVersion": "2023-01-01",
                    "name": "StorageAccounts",
                    "properties": {
                      "pricingTier": "Standard"
                    }
                  }
                ],
                "outputs": {}
              }
            }
          }
        }
      }
    },
    "versions": [
      "1.1.0",
      "1.0.2"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/74c30959-af11-47b3-9ed2-a26e03f427a3",
  "name": "74c30959-af11-47b3-9ed2-a26e03f427a3"
}
Bylaw74c30959-af11-47b3-9ed2-a26e03f427a3.bylaw.ps1 · 34 lines
# Converted from ASC_Azure_Defender_Storage_DINE.json by ConvertTo-Bylaw.
Policy '74c30959-af11-47b3-9ed2-a26e03f427a3' {

    Properties @{
        DisplayName   = '[Deprecated]: Configure Microsoft Defender for Storage (Classic) to be enabled'
        Description   = 'Microsoft Defender for Storage (Classic) provides detections of unusual and potentially harmful attempts to access or exploit storage accounts - please note that deprecation is for commercial cloud only.'
        Version       = '1.1.0-deprecated'
        Category      = 'Security Center'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Resources/subscriptions'

    DeployIfNotExists 'Microsoft.Security/pricings' -Role 'Security Admin' -Name 'StorageAccounts' -ExistenceScope Subscription -Effect (Param Effect) {
        Require 'pricingTier is Standard' {
            Field pricingTier | Must -Be 'Standard'
        }
        Deployment @{
            TemplateFile = './templates/74c30959-af11-47b3-9ed2-a26e03f427a3.json'
            Scope        = 'Subscription'
            Location     = 'westeurope'
        }
    }
}

Its deployment templates are written beside it:

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