Bylaw

Gallery › Container Registry › Azure built-in policies

Container registries should prevent cache rule creation

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Disable cache rule creation for your Azure Container Registry to prevent pull through cache pulls. Learn more at: https://aka.ms/acr/cache.

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

Azure Policy JSONACR_PTCDisabled_AuditDeny.json · 42 lines
{
  "properties": {
    "displayName": "Container registries should prevent cache rule creation",
    "description": "Disable cache rule creation for your Azure Container Registry to prevent pull through cache pulls. Learn more at: https://aka.ms/acr/cache.",
    "policyType": "BuiltIn",
    "mode": "All",
    "metadata": {
      "version": "1.0.0",
      "category": "Container Registry"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ContainerRegistry/registries/cacheRules"
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/84497762-32b6-4ab3-80b6-732ea48b85a2",
  "name": "84497762-32b6-4ab3-80b6-732ea48b85a2"
}
Bylaw84497762-32b6-4ab3-80b6-732ea48b85a2.bylaw.ps1 · 23 lines
# Converted from ACR_PTCDisabled_AuditDeny.json by ConvertTo-Bylaw.
Policy '84497762-32b6-4ab3-80b6-732ea48b85a2' {

    Properties @{
        DisplayName   = 'Container registries should prevent cache rule creation'
        Description   = 'Disable cache rule creation for your Azure Container Registry to prevent pull through cache pulls. Learn more at: https://aka.ms/acr/cache.'
        Version       = '1.0.0'
        Category      = 'Container Registry'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.ContainerRegistry/registries/cacheRules'

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Container Registry/ACR_PTCDisabled_AuditDeny.json in Azure/azure-policy, under the MIT licence.