Azure Cache for Redis no Connection

145 Views Asked by At

I have this Azure Cache for Redis which it's working when I add my IP to the Firewall

enter image description here

But when I run the App Service I get the following error:

The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: It was not possible to connect to the redis server(s). ConnectTimeout, command=HMGET, timeout: 5000

I know that when I remove my IP, I get the same error while running the application locally, so I imagine that it's the same issue. But since the application and the Redis it's in the same Azure account, how am I supposed to configure the Redis to became accessible from the application?

1

There are 1 best solutions below

1
On

Option 1 : App service on its own has a bunch of IPs. You can find the IP your App service is using by referring to this link. A powershell command to do this is.

(Get-AzWebApp -ResourceGroup <group_name> -name <app_name>).OutboundIpAddresses

But the IP address may change as depicted on this LINK. Also, this is not the best security as you are adding IPs that are used by other App services that do not necessarily belong to you. But it does decrease the risk substantially.

Option 2 : Use a Natgateway associated to a subnet to which the App service is integrated. Ofcourse, for this, you need to integrate your App service to a VNET3. Refer to this documentation as well. The data still travels over the public internet.

Option 3 : The secure way which prevents the data from travelling through the public network is to integrate your app service to a VNET and then integrate it with your redis using a private endpoints.