Add an NSG with Redis security rules to an existing subnet

Azure Public Test Date Azure Public Test Result

Azure US Gov Last Test Date Azure US Gov Last Test Result

Best Practice Check Cred Scan Check

Deploy To Azure Deploy To Azure US Gov Visualize

Tags: redis, cache, vnet, nsg, Microsoft.Network/networkSecurityGroups, Microsoft.Resources/deployments, Microsoft.Network/virtualNetworks/subnets, Microsoft.Network/virtualNetworks


If an NSG with the same name and resource group already exists, it will be replaced with the new NSG. All existing security rules in the old NSG will be lost. If other subnets are associated with the NSG, they will remain associated with the new NSG and its new security rules.

The VNet and NSG must be located in the same region to be associated. The VNet and NSG do not have to be in the same resource group.

Solution overview and deployed resources

This template deploys a Network Security Group. The NSG is preconfigured with security rules to allow Azure Redis Cache to operate within an existing Virtual Network.

The following resources are deployed as part of the solution

Network Security Groups

This template deployes a Network Security Group

  • Microsoft.Network/networkSecurityGroups: the new Network Security Group with preconfigured Azure Redis Cache security rules

Virtual Networks

This template associates the new NSG with an existing subnet within an existing Virtual Network in the same region

  • Microsoft.Network/virtualNetworks: an existing Virtual Network and subnet


An existing Virtual Network and subnet is required before deploying this template. Learn more about the VNet requirements for Azure Redis Cache here. The provided prerequisite templates may be used to deploy the required VNet.

Deployment steps

You can click the "deploy to Azure" button at the beginning of this document or follow the instructions for command line deployment using the scripts in the root of this repo.