Bylaw

Gallery › Storage › Azure Community Policy

Deny deletion of storage account

Converted Policy DenyAction Disabled Mode Indexed Version 1.0.0 Preview

need to add description

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

Azure Policy JSONazurepolicy.json · 42 lines
{
  "name": "2bd865e5-1348-42ee-ac24-690b44f88f1f",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Deny deletion of storage account",
    "description": "need to add description",
    "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": [
          "DenyAction",
          "Disabled"
        ],
        "defaultValue": "DenyAction"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Storage/storageAccounts"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "actionNames": [
            "delete"
          ]
        }
      }
    }
  }
}
Bylaw2bd865e5-1348-42ee-ac24-690b44f88f1f.bylaw.ps1 · 23 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '2bd865e5-1348-42ee-ac24-690b44f88f1f' {

    Properties @{
        DisplayName = 'Deny deletion of storage account'
        Description = 'need to add description'
        Version     = '1.0.0'
        Category    = 'Storage'
        Preview     = $true
        Mode        = 'Indexed'
    }

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

    Resource 'Microsoft.Storage/storageAccounts'

    DenyAction Delete -Effect (Param Effect)
}

Source: policyDefinitions/Storage/deny-deletion-of-storage-account/azurepolicy.json in Azure/Community-Policy, under the MIT licence.