【Azure 应用服务】遇见“无法创建hybrid connection for App Service”的解决办法
Hybrid Connection (混合连接) 在两个联网应用程序之间启用了双向、请求-响应和二进制流通信以及简单的数据报流。通过混合连接,可以实现应用部署在公网环境中,而数据库保存在本地私网环境中,他们之间通过(HCM: 混合连接器)实现双向通信。
工作原理
混合连接要求将中继代理部署到可以同时到达所需终结点和 Azure 的位置。 中继代理混合连接管理器 (HCM) 通过端口 443 调用 Azure 中继。 在 Web 应用站点上,应用服务基础结构还代表应用程序连接到 Azure 中继。 通过已联接的连接,应用可以访问所需的终结点。 连接使用 TLS 1.2 来确保安全,使用共享访问签名 (SAS) 密钥进行身份验证和授权。
问题描述
在参照设置文档 “Azure 应用服务混合连接” 一步一步配置好HCM(Hybrid Connection Manager: 混合连接管理器)后,使用数据库的IP地址作为配置的Endpoint,在HCM中显示,状态为connected,但是应用中连接DB时,出现错误。无法动过HCM的方式成功连接到DB。
配置显示成功截图:
应用错误消息:
an error occured: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
问题解答
客户端无法连接到其终结点的主要原因是使用 IP 地址而不是 DNS 名称指定了终结点。
如果应用无法访问所需的终结点,而你使用了 IP 地址,请改为使用在运行 HCM 的主机上有效的 DNS 名称。 另请检查 DNS 名称是否能够在运行 HCM 的主机上正确解析。 确认运行 HCM 的主机是否与混合连接终结点建立了连接。
If your status says Connected but your app cannot reach your endpoint then:
- make sure you are using a DNS name in your Hybrid Connection. If you use an IP address then the required client DNS lookup may not happen. If the client running in your web app does not do a DNS lookup, then the Hybrid Connection will not work
- check that the DNS name used in your Hybrid Connection can resolve from the HCM host. Check the resolution using nslookup EndpointDNSname where EndpointDNSname is an exact match to what is used in your Hybrid Connection definition.
- test access from your HCM host to your endpoint using the PowerShell command Test-NetConnection EndpointDNSname -P Port If you cannot reach the endpoint from your HCM host then check firewalls between the two hosts including any host-based firewalls on the destination host.
解决办法
把配置在HCM连接中的Endpoint中改为数据库的主机名,如果是域环境,必须是完整的,可解析的DNS。(安装HCM的机器和真实的DB机器之间可以成功nslookup 且 test-netconnection 成功)
参考文档
Azure 应用服务混合连接:https://docs.azure.cn/zh-cn/app-service/app-service-hybrid-connections#troubleshooting
Using Azure App Services with Hybrid Connections:https://www.cnblogs.com/lulight/articles/14786533.html
- 【Azure 应用程序见解】在Azure门户中,创建App Service(应用服务)时,无法一起创建Application Insights的问题
- 【Azure App Service For Container】创建ASP.NET Core Blazor项目并打包为Linux镜像发布到Azure应用服务
- 【Azure 应用服务】App Service中抓取 Web Job 的 DUMP 办法
- 【应用服务 App Service】在Azure Web App的部署文件中,是否可以限制某些文件无法被访问?(如json)
- 【Azure 应用服务】App Service for Container中配置与ACR(Azure Container Registry)的RABC权限
- 【Azure 应用服务】在Azure App Service for Windows 中部署Java/NodeJS/Python项目时,web.config的配置模板内容
- 关于客户端无法获得服务器端GP服务(Geoprocessing Service)结果的解决办法
- 在 UWP 应用中创建、使用、调试 App Service (应用服务)
- 添加Service Reference, 无法为服务生成代码错误的解决办法
- 问题:Custom tool error: Failed to generate code for the service reference 'AppVot;结果:添加Service Reference, 无法为服务生成代码错误的解决办法
- 【Azure 应用服务】App Service 默认开放端口说明, 如何禁用Web app的端口号?
- 关于iphone6安装了727个应用后,更新app 导致一些app无法更新,无法删除,重启后消失,但是却还是占用空间的解决办法
- 百度语音应用push 到 system/app无法加载动态库解决办法
- 添加Service Reference, 无法为服务生成代码错误的解决办法
- 添加Service Reference, 无法为服务生成代码错误的解决办法
- 使用dubbo注解@Service注册服务后使用aop或者申明式事物导致无法注册的问题解决办法
- 无法向会话状态服务器发出会话状态请求。请确保 ASP.NET State Service (ASP.NET 状态服务)已启动,并且客户端端口与服务器端口相同。解决办法:
- 关于客户端无法获得服务器端GP服务(Geoprocessing Service)结果的解决办法
- 【Azure 应用服务】Azure App Service (Windows) 使用Flask框架部署Python应用,如何在代码中访问静态文件呢?如何设置文件路径?是相对路径还是绝对路径呢?
- 【Azure 应用服务】记一次Azure Spring Cloud 的部署错误 (az spring-cloud app deploy -g dev -s testdemo -n demo -p ./hellospring-0.0.1-SNAPSHOT.jar --->>> Failed to wait for deployment instances to be ready)