Bylaw

Gallery › Storage › Azure Landing Zones Library

Virtual network rules should be restricted for Storage Accounts

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Azure Storage accounts should restrict the virtual network service-level network ACLs. Enforce this for increased data exfiltration protection.

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

Azure Policy JSONDeny-Storage-NetworkAclsVirtualNetworkRules.alz_policy_definition.json · 54 lines
{
  "name": "Deny-Storage-NetworkAclsVirtualNetworkRules",
  "properties": {
    "description": "Azure Storage accounts should restrict the virtual network service-level network ACLs. Enforce this for increased data exfiltration protection.",
    "displayName": "Virtual network rules should be restricted for Storage Accounts",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Storage/storageAccounts",
            "field": "type"
          },
          {
            "count": {
              "field": "Microsoft.Storage/storageAccounts/networkAcls.virtualNetworkRules[*]"
            },
            "greater": 0
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Storage-NetworkAclsVirtualNetworkRules.bylaw.ps1 · 28 lines
# Converted from Deny-Storage-NetworkAclsVirtualNetworkRules.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Storage-NetworkAclsVirtualNetworkRules' {

    Properties @{
        DisplayName = 'Virtual network rules should be restricted for Storage Accounts'
        Description = 'Azure Storage accounts should restrict the virtual network service-level network ACLs. Enforce this for increased data exfiltration protection.'
        Category    = 'Storage'
        Version     = '1.0.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

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

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'networkAcls.virtualNetworkRules is as required' {
            Count 'networkAcls.virtualNetworkRules[*]' | Must -Be 0
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-Storage-NetworkAclsVirtualNetworkRules.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.