Bylaw

Gallery › Storage › Azure Community Policy

Deny local authentication usage on Azure Storage

Converted Policy Deny Disabled Mode Indexed Version 1.0.0 Preview

Deny the creation and update of Storage Accounts if local authentication enabled.

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

Azure Policy JSONazurepolicy.json · 49 lines
{
  "name": "a27baf66-45ee-4d9c-bad6-aa292155e1af",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Deny local authentication usage on Azure Storage",
    "description": "Deny the creation and update of Storage Accounts if local authentication enabled.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage",
      "preview": true
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "DenyAction or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny"
      }
    },
    "policyRule": {
      "if": {
        "anyOf": [
          {
            "field": "Microsoft.Storage/storageAccounts/allowSharedKeyAccess",
            "equals": true
          },
          {
            "field": "Microsoft.Storage/storageAccounts/allowBlobPublicAccess",
            "equals": true
          },
          {
            "field": "Microsoft.Storage/storageAccounts/defaultToOAuthAuthentication",
            "equals": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawa27baf66-45ee-4d9c-bad6-aa292155e1af.bylaw.ps1 · 36 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'a27baf66-45ee-4d9c-bad6-aa292155e1af' {

    Properties @{
        DisplayName = 'Deny local authentication usage on Azure Storage'
        Description = 'Deny the creation and update of Storage Accounts if local authentication enabled.'
        Version     = '1.0.0'
        Category    = 'Storage'
        Preview     = $true
        Mode        = 'Indexed'
    }

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

    Resource * {

        Require 'allowSharedKeyAccess is not true' {
            Field 'Microsoft.Storage/storageAccounts/allowSharedKeyAccess' | Must -Not -Be $true -IfPresent
        }

        Require 'allowBlobPublicAccess is not true' {
            Field 'Microsoft.Storage/storageAccounts/allowBlobPublicAccess' | Must -Not -Be $true -IfPresent
        }

        Require 'defaultToOAuthAuthentication is not false' {
            Field 'Microsoft.Storage/storageAccounts/defaultToOAuthAuthentication' | Must -Not -Be $false -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Storage/deny-local-authentication-usage/azurepolicy.json in Azure/Community-Policy, under the MIT licence.