'How can I deny all the public access to my azure cache for redis?

I want to deny all the public traffic from accessing my cache redis, I could not find any proper solution, any help will be appriciated.



Solution 1:[1]

As the question is about denying the public traffic, I would suggest you to do it via Azure built in policy.

Azure Cache for Redis should disable public network access denies the public endpoint access. Assign this at the appropriate level in your tenant.

Here is the snippet from above policy definition::

"policyRule": {
  "if": {
    "allOf": [
      {
        "field": "type",
        "equals": "Microsoft.Cache/Redis"
      },
      {
        "field": "Microsoft.Cache/Redis/publicNetworkAccess",
        "notEquals": "Disabled"
      }
    ]
  },
  "then": {
    "effect": "[parameters('effect')]"
  }
}

Solution 2:[2]

You can make use of Private Endpoint to do that. Instructions specific to securing an Azure Cache for Redis so that it is not accessible publicly can be found here: https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-private-link.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 harshavmb
Solution 2 Gaurav Mantri