【Azure API 管理】APIM不能连接到 App Service (APIM cannot connect to APP service)
问题描述
APIM 无法正确连接到App Service,返回500错误:
{
"statusCode": 500,
"message": "Internal server error",
"activityId": "2aef4474-4067-a333-8750-3889ebad3eeb"
}
单独访问App Service,是可以成功的。当通过APIM访问时候就出现了500错误
问题分析
根据博文“【Azure API 管理】为调用APIM的请求启用Trace -- 调试APIM Policy的利器” 中的内容,启用APIM Trace后,在 Backend 发现真实的错误消息为:
error message :The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
这个错误信息指示,后端服务适用的证书问题。当APIM的后端服务所配置的证书为自签名证书,而不是根CA证书时,通常就会遇见此错误。 APIM服务部署在Windows操作系统所运行的PaaS VM托管上的Azure服务中。因此每个APIM实例都信任所有Windows 系统默认的根证书颁发机构。这个问题的解决办法为:
1:添加一个由受信任的CA机构颁发证书到App Service上。
2:禁止APIM与后端App Service之间的证书链验证。使用 New-AzApiManagementBackend 或 Set-AzApiManagementBackend 对APIM中所配置的后端服务 设置-SkipCertificateChainValidation 为True。
示例命令为:
$context = New-AzApiManagementContext -resourcegroup 'ContosoResourceGroup' -servicename 'ContosoAPIMService' New-AzApiManagementBackend -Context $context -Url 'https://contoso.com/myapi' -Protocol http -SkipCertificateChainValidation $true
参考文档
Set-AzApiManagementBackend :https://docs.microsoft.com/en-us/powershell/module/az.apimanagement/set-azapimanagementbackend?view=azps-7.3.0&viewFallbackFrom=azps-4.8.0
New-AzApiManagementBackend :https://docs.microsoft.com/en-us/powershell/module/az.apimanagement/new-azapimanagementbackend?view=azps-7.3.0&viewFallbackFrom=azps-4.8.0
Troubleshooting 4xx and 5xx Errors with Azure APIM services : https://techcommunity.microsoft.com/t5/azure-paas-blog/troubleshooting-4xx-and-5xx-errors-with-azure-apim-services/ba-p/2115744
Scenario 7: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
Symptom:
API requests fail with Backend Connection Failure with the below error message highlighted under the errorMessage column in the diagnostic logs:
“The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel”
Cause:
This error is normally encountered when the backend has been configured to use a self-signed certificate instead of using a publicly trusted root CA certificate.
APIM services are hosted in the Azure infrastructure using PaaS VMs that run on Windows OS.
Hence, every APIM instance trusts the same default Root Certificate Authorities that all windows machines trust.
The list of trusted Root CAs can be downloaded using the Microsoft Trusted Root Certificate Program Participants list - https://docs.microsoft.com/en-us/security/trusted-root/participants-list
Resolution:
There are 2 possible solutions for resolving this issue:
- Add a valid trusted root CA certificate that resolves to a Microsoft Trusted Root Participant list.
- Disable certificate chain validation in order for APIM to communicate with the backend system. To configure this, you can use the New-AzApiManagementBackend (for new back end) or Set-AzApiManagementBackend (for existing back end) PowerShell cmdlets and set the -SkipCertificateChainValidation parameter to True.
【Azure API 管理】APIM不能连接到 App Service (APIM cannot connect to APP service)的更多相关文章
- 【Azure API 管理】从微信小程序访问APIM出现200的空响应的问题中发现CORS的属性[terminate-unmatched-request]功能
问题描述 使用微信小程序调用APIM(API Management)中的接口,发现POST和PUT请求被拦截,返回的状态码为200,但是无消息内容. 在小程序中的调用JS代码如: 通过浏览器测试得到的 ...
- 【Azure API 管理】APIM集成内网虚拟网络后,启用自定义路由管理外出流量经过防火墙(Firewall),遇见APIs加载不出来问题
问题描述 使用 Azure 虚拟网络,Azure APIM 可以管理无法通过 Internet 访问的 API,达到以保护企业内部的后端API的目的.在虚拟网络中,启用网络安全组(NSG:Networ ...
- 【Azure API 管理】在APIM 中添加 log-to-eventhub 策略,把 Request Body 信息全部记录在Event Hub中
问题描述 根据文档 https://docs.azure.cn/zh-cn/api-management/api-management-howto-log-event-hubs, 可以将Azure A ...
- 【Azure API 管理】为调用APIM的请求启用Trace -- 调试APIM Policy的利器
问题描述 在APIM中,通过门户上的 Test 功能,可以非常容易的查看请求的Trace信息,帮助调试 API 对各种Policy,在Inbound,Backend, Outbound部分的耗时问题, ...
- 【Azure API 管理】Azure APIM服务集成在内部虚拟网络后,在内部环境中打开APIM门户使用APIs中的TEST功能失败
问题描述 使用微软API管理服务(Azure API Management),简称APIM. 因为公司策略要求只能内部网络访问,所以启用了VNET集成.集成方式见: (在内部模式下使用 Azure A ...
- 【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
问题描述 为APIM添加AAD Group时候,等待很长很长的时间,结果添加失败.错误消息为: Write Groups ValidationError :Failed to query Azure ...
- 【Azure API 管理】在APIM中使用客户端证书验证API的请求,但是一直提示错误"No client certificate received."
API 管理 (APIM) 是一种为现有后端服务创建一致且现代化的 API 网关的方法. 问题描述 在设置了APIM客户端证书,用户保护后端API,让请求更安全. 但是,最近发现使用客户端证书的API ...
- 【Azure API 管理】APIM 配置Validate-JWT策略,验证RS256非对称(公钥/私钥)加密的Token
问题描述 在APIM中配置对传入的Token进行预验证,确保传入后端被保护的API的Authorization信息正确有效,可以使用validate-jwt策略.validate-jwt 策略强制要求 ...
- 【Azure API 管理】APIM如何实现对部分固定IP进行访问次数限制呢?如60秒10次请求
问题描述 使用Azure API Management, 想对一些固定的IP地址进行访问次数的限制,如被限制的IP地址一分钟可以访问10次,而不被限制的IP地址则可以无限访问? ChatGPT 解答 ...
- 【Azure API 管理】API Management如何有效且快速更新呢?如对APIs/Policy等设置内容
问题描述 APIM中的内容(API, Policy)等内容,如果有需要更新时候,通常可以在Azure APIM门户上操作,通过一个接口一个设置的修改,也可以针对一个接口导入/导出的方式修改.当APIM ...
随机推荐
- CPU 大拿的作品
http://nieyong.github.io/wiki_cpu/index.html 改天学习写一下.
- C# 输入指定日期获取当前年的第一天 、当前年的最后天、某月的第一天 、某月的最后一天
方法 /// <summary> /// 取得当前年的第一天 /// </summary> /// <param name="datetime"> ...
- 在mac中双击执行python
执行python脚本 mac有内置的python,但还是建议你自己安装一个python,如果没有卸载mac自带的python2.7,当你需要使用python3执行脚本时,python命令需要改为pyt ...
- TienChin-课程管理-课程导出
更改 Course.java: /** * 课程ID */ @TableId(value = "course_id", type = IdType.AUTO) @NotNull(m ...
- C/C++ 使用API实现数据压缩与解压缩
在Windows编程中,经常会遇到需要对数据进行压缩和解压缩的情况,数据压缩是一种常见的优化手段,能够减小数据的存储空间并提高传输效率.Windows提供了这些API函数,本文将深入探讨使用Windo ...
- Python 实现文件关键字扫描
第一段代码用户传入一个文件夹,自动扫描文件夹内特定文件是否存在某些关键字,如果存在则输出该文件的路径信息. # coding=gbk import sys,os,re def spider(scrip ...
- nftables用法介绍
Kubernetes 1.29版本中已经将nftables作为一个featureGates,本文简单整理了nftables的用法,便于后续理解kubernetes的nftables规则.文末给出了使用 ...
- Linux-mysql的备份与恢复
数据库 备份 mysqldump(mysql自带备份功能) - 锁表 - 备份特别慢,适用于数据量较小 - 不可以做增量备份 - 单线程 ``` -A, --all-databases 所有的库 -B ...
- nginx入门之基础配置
1.配置文件 nginx 的配置文件是 /etc/nginx/nginx.conf,其目录结构大致为: main #全局配置,对全局生效 events { #nginx工作模式配置,配置影响 Ngin ...
- .net 工具箱不可用/怎样初始化vs环境 解决方案
在开始菜单里面执行的.开始菜单->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 命令提示 ...