• 【Azure 应用服务】App Service 项目部署成功后,应用连接 Azure Redis时报错 Could not get a resource from the pool


    问题描述

    App Service 项目部署成功后,需要连接到同在云上的Redis服务, Redis启动了专用终结点,只能在于Redis同一个VNET(虚拟网络)的资源能够访问。在进入App Service的Bash中使用Paping测试Redis的网络连通性,验证是通的。但是为什么应用程序中一直出错呢?

    Bash中使用Paping:

    应用程序中的错误信息:

    [INFO]  org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; 
    nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to xxxxxxx.redis.cache.chinacloudapi.cn:6380
    
    at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection(LettucePoolingConnectionProvider.java:86) 
    ~[spring-data-redis-2.0.6.RELEASE.jar!/:2.0.6.RELEASE]

    问题分析

    App Service配置了VNET后,可以在Bash中paping通Redis服务,表示从App Service到Redis之间的网络链路是相通的。但是为什么在应用中就是连接不上Redis呢?

    仔细查看App Service的文档后,是由于应用与 VNet 集成后,它将使用 VNet 配置的 DNS 服务器。 默认情况下,应用不能用于 Azure DNS 专用区域。需要添加设置(WEBSITE_VNET_ROUTE_ALL & WEBSITE_DNS_SERVER )将所有出站调用从应用发送到 VNet,并允许应用访问 Azure DNS 专用区域。

    添加配置参数如下后,应用调用Redis成功。

    WEBSITE_VNET_ROUTE_ALL = 1
    WEBSITE_DNS_SERVER = 168.63.129.16

    但是在App Service for Linux环境中,可以通过全部路由( Route All) 功能来代替 WEBSITE_VNET_ROUTE_ALL 配置。

    注意:配置应用程序路由时,可将所有流量或仅将专用流量路由到 VNet。 通过“全部路由(Route All)”设置来配置此设置。

    参考资料:

    将应用与 Azure 虚拟网络集成:https://docs.microsoft.com/zh-cn/azure/app-service/web-sites-integrate-with-vnet#regional-vnet-integration

    Azure DNS 专用区域: https://docs.azure.cn/zh-cn/app-service/web-sites-integrate-with-vnet#azure-dns-private-zones

    当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

  • 相关阅读:
    万网免费主机wordpress快速建站教程-域名绑定及备案
    java小算法—大衍数列
    Core Data使用之一(Swift): 保存
    Swift 添加到TableView实现动画效果
    Swift 动态创建提示框
    Swift分割字符串
    Swift去除两边的特定字符(空格或其它)
    windows 属性
    String 输出{}
    c# 正则表达式的用户
  • 原文地址:https://www.cnblogs.com/lulight/p/15244717.html
Copyright © 2020-2023  润新知