01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:
az account list
--query '[*].id'
02 The command output should return the requested subscription identifiers (IDs):
[
"abcdabcd-1234-abcd-1234-abcdabcdabcd",
"abcd1234-abcd-1234-abcd-abcd1234abcd"
]
03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to examine as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):
az account set
--subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
04 Run network nsg create command (Windows/macOS/Linux) to create a new Network Security Group (NSG) for your Microsoft Azure Cache for Redis server:
az network nsg create
--name cc-redis-cache-nsg
--resource-group cloud-shell-storage-westeurope
--location westeurope
--query 'NewNSG.provisioningState'
05 The command output should return the NSG provisioning status:
06 Run network nsg rule create command (Windows/macOS/Linux) with the name of the Network Security Group (NSG) that you want to configure as the identifier parameter, to allow inbound traffic from known, trusted IP addresses, on specific ports only:
az network nsg rule create
--name AllowRedisInboundAccess
--nsg-name cc-redis-cache-nsg
--resource-group cloud-shell-storage-westeurope
--direction Inbound
--access Allow
--protocol Tcp
--priority 300
--source-address-prefixes 10.20.30.40/32
--destination-port-ranges 6380
--destination-address-prefixes '*'
--description "Allow inbound traffic on TCP port 6380 (Redis Cache)"
07 The command output should return the information available for the new NSG rule:
{
"access": "Allow",
"description": "Allow inbound traffic on TCP port 6380 (Redis Cache)",
"destinationAddressPrefix": "*",
"destinationAddressPrefixes": [],
"destinationPortRange": "6380",
"destinationPortRanges": [],
"direction": "Inbound",
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/networkSecurityGroups/cc-redis-cache-nsg/securityRules/AllowRedisInboundAccess",
"name": "AllowRedisInboundAccess",
"priority": 300,
"protocol": "Tcp",
"provisioningState": "Succeeded",
"resourceGroup": "cloud-shell-storage-westeurope",
"sourceAddressPrefix": "10.20.30.40/32",
"sourceAddressPrefixes": [],
"sourcePortRange": "*",
"sourcePortRanges": [],
"type": "Microsoft.Network/networkSecurityGroups/securityRules"
}
08 Run network nsg rule create command (Windows/macOS/Linux) with the name of the Network Security Group (NSG) that you want to configure as the identifier parameter, to allow outbound traffic to known, trusted IP addresses, on specific ports only:
az network nsg rule create
--name AllowRedisOutboundAccess
--nsg-name cc-redis-cache-nsg
--resource-group cloud-shell-storage-westeurope
--direction Outbound
--access Allow
--protocol Tcp
--priority 500
--source-address-prefixes '*'
--destination-port-ranges 6380
--destination-address-prefixes 10.20.30.40/32
--description "Allow outbound traffic on TCP port 6380 (Redis Cache)"
09 The command output should return the information available for the new NSG rule:
{
"access": "Allow",
"description": "Allow outbound traffic on TCP port 6380 (Redis Cache)",
"destinationAddressPrefix": "10.20.30.40/32",
"destinationAddressPrefixes": [],
"destinationPortRange": "6380",
"destinationPortRanges": [],
"direction": "Outbound",
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/networkSecurityGroups/cc-redis-cache-nsg/securityRules/AllowRedisOutboundAccess",
"name": "AllowRedisOutboundAccess",
"priority": 500,
"protocol": "Tcp",
"provisioningState": "Succeeded",
"resourceGroup": "cloud-shell-storage-westeurope",
"sourceAddressPrefix": "*",
"sourceAddressPrefixes": [],
"sourcePortRange": "*",
"sourcePortRanges": [],
"type": "Microsoft.Network/networkSecurityGroups/securityRules"
}
10 Run redis show command (Windows/macOS/Linux) with custom output filters to describe the ID of subnet configured for virtual network (VNet) integration with the specified Azure Cache for Redis server:
az redis show
--name cc-project5-redis-cache
--resource-group cloud-shell-storage-westeurope
--query '{"subnetId":subnetId}'
11 The command output should return the ID of the associated VNet subnet:
{
"subnetId": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/virtualNetworks/cc-project5-vnet/subnets/cc-vnet-subnet-001"
}
12 Run network vnet subnet update command (Windows/macOS/Linux) to attach the Network Security Group (NSG) created earlier in the Remediation process to the VNet subnet configured for your cache server VNet integration, returned at the previous step:
az network vnet subnet update
--ids "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/virtualNetworks/cc-project5-vnet/subnets/cc-vnet-subnet-001"
--network-security-group cc-redis-cache-nsg
13 The command output should return the information available for configured VNet subnet:
{
"addressPrefixes": [
"10.0.0.0/24"
],
"delegations": [],
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/virtualNetworks/cc-project5-vnet/subnets/cc-vnet-subnet-001",
"name": "cc-vnet-subnet-001",
"networkSecurityGroup": {
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/networkSecurityGroups/cc-redis-cache-nsg",
"resourceGroup": "cloud-shell-storage-westeurope"
},
"privateEndpointNetworkPolicies": "Disabled",
"privateLinkServiceNetworkPolicies": "Enabled",
"provisioningState": "Succeeded",
"resourceGroup": "cloud-shell-storage-westeurope",
"type": "Microsoft.Network/virtualNetworks/subnets"
}
14 Repeat steps no. 4 – 13 for each Azure Cache for Redis server that you want to configure, deployed in the selected Azure subscription.
15 Repeat steps no. 3 – 14 for each subscription created within your Microsoft Azure cloud account.