Bylaw

Gallery › Cache › Azure built-in policies

Azure Cache for Redis should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling public network access improves security by ensuring that the Azure Cache for Redis isn't exposed on the public internet. You can limit exposure of your Azure Cache for Redis by creating private endpoints instead. Learn more at: https://docs.microsoft.com/azure/azure-cache-for-redis/cache-private-link.

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

Azure Policy JSONRedisCache_PublicNetworkAccess_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Azure Cache for Redis should disable public network access",
    "description": "Disabling public network access improves security by ensuring that the Azure Cache for Redis isn't exposed on the public internet. You can limit exposure of your Azure Cache for Redis by creating private endpoints instead. Learn more at: https://docs.microsoft.com/azure/azure-cache-for-redis/cache-private-link.",
    "metadata": {
      "version": "1.0.0",
      "category": "Cache"
    },
    "version": "1.0.0",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Cache/Redis"
          },
          {
            "field": "Microsoft.Cache/Redis/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/470baccb-7e51-4549-8b1a-3e5be069f663",
  "name": "470baccb-7e51-4549-8b1a-3e5be069f663"
}
Bylaw470baccb-7e51-4549-8b1a-3e5be069f663.bylaw.ps1 · 28 lines
# Converted from RedisCache_PublicNetworkAccess_AuditDeny.json by ConvertTo-Bylaw.
Policy '470baccb-7e51-4549-8b1a-3e5be069f663' {

    Properties @{
        DisplayName   = 'Azure Cache for Redis should disable public network access'
        Description   = 'Disabling public network access improves security by ensuring that the Azure Cache for Redis isn''t exposed on the public internet. You can limit exposure of your Azure Cache for Redis by creating private endpoints instead. Learn more at: https://docs.microsoft.com/azure/azure-cache-for-redis/cache-private-link.'
        Version       = '1.0.0'
        Category      = 'Cache'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Cache/Redis' {

        Require 'publicNetworkAccess is Disabled' {
            Field publicNetworkAccess | Must -Be 'Disabled'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Cache/RedisCache_PublicNetworkAccess_AuditDeny.json in Azure/azure-policy, under the MIT licence.