Bylaw

Gallery › Cache › Azure built-in policies

Azure Cache for Redis should not use access keys for authentication

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Not using local authentication methods like access keys and using more secure alternatives like Microsoft Entra ID (recommended) improves security for your Azure Cache for Redis. Learn more at aka.ms/redis/disableAccessKeyAuthentication

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

Azure Policy JSONRedisCache_DisableAccessKeysAuth_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Azure Cache for Redis should not use access keys for authentication",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Not using local authentication methods like access keys and using more secure alternatives like Microsoft Entra ID (recommended) improves security for your Azure Cache for Redis. Learn more at aka.ms/redis/disableAccessKeyAuthentication",
    "metadata": {
      "version": "1.0.0",
      "category": "Cache"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Cache/Redis"
          },
          {
            "field": "Microsoft.Cache/Redis/disableAccessKeyAuthentication",
            "equals": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/3827af20-8f80-4b15-8300-6db0873ec901",
  "name": "3827af20-8f80-4b15-8300-6db0873ec901"
}
Bylaw3827af20-8f80-4b15-8300-6db0873ec901.bylaw.ps1 · 28 lines
# Converted from RedisCache_DisableAccessKeysAuth_Audit.json by ConvertTo-Bylaw.
Policy '3827af20-8f80-4b15-8300-6db0873ec901' {

    Properties @{
        DisplayName   = 'Azure Cache for Redis should not use access keys for authentication'
        Description   = 'Not using local authentication methods like access keys and using more secure alternatives like Microsoft Entra ID (recommended) improves security for your Azure Cache for Redis. Learn more at aka.ms/redis/disableAccessKeyAuthentication'
        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 'disableAccessKeyAuthentication is not false' {
            Field disableAccessKeyAuthentication | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effect)
}

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