Bylaw

Gallery › Storage › Azure Community Policy

Storage Account - Read Access Logs and Metrics AUDIT

Converted Policy Audit Disabled Mode All Version 1.0.0

This Azure Policy creates an audit event when the 'Allow read access to storage logging from any network' and 'Allow read access to storage metrics from any network' settings are 'Enabled'.

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

Azure Policy JSONazurepolicy.json · 52 lines
{
  "name": "840211b4-51d6-4ecb-8efc-1adcac2af2ad",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Storage Account - Read Access Logs and Metrics AUDIT",
    "description": "This Azure Policy creates an audit event when the 'Allow read access to storage logging from any network' and 'Allow read access to storage metrics from any network' settings are 'Enabled'.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Storage/storageAccounts/networkAcls.bypass",
                "contains": "Logging"
              },
              {
                "field": "Microsoft.Storage/storageAccounts/networkAcls.bypass",
                "contains": "Metrics"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw840211b4-51d6-4ecb-8efc-1adcac2af2ad.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '840211b4-51d6-4ecb-8efc-1adcac2af2ad' {

    Properties @{
        DisplayName = 'Storage Account - Read Access Logs and Metrics AUDIT'
        Description = 'This Azure Policy creates an audit event when the ''Allow read access to storage logging from any network'' and ''Allow read access to storage metrics from any network'' settings are ''Enabled''.'
        Version     = '1.0.0'
        Category    = 'Storage'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'networkAcls.bypass does not contain Logging' {
            Field networkAcls.bypass | Must -Not -ContainText 'Logging' -IfPresent
        }

        Require 'networkAcls.bypass does not contain Metrics' {
            Field networkAcls.bypass | Must -Not -ContainText 'Metrics' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Storage/storage-account-read-access-logs-and-metrics-audit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.