从Azure App Service到API的API呼叫托管在Azure VM上托管的API - 试图以其访问权限禁止



API呼叫从Azure应用程序服务到Azure vm

托管的API

当我的Azure Chat Bot拨打API时,我会收到以下错误消息,该通话托管在Azure VM上。我的应用服务/Web应用程序机器人都在同一资源组上。

发生一个或多个错误。(试图访问插座 在某种程度上,其访问权限禁止(---> system.net.http.httprequestexception:尝试访问 插座以其访问权限禁止的方式---> System.net.sockets.socketException:尝试访问 插座以某种方式禁止其访问权限 system.net.http.connecthelper.connectasync(字符串主机,int32端口, comcellationtoken concellationToken(---内部异常的结尾 堆栈跟踪---在 system.net.http.connecthelper.connectasync(字符串主机,int32端口, 取消tocellation tocellationToken( system.threading.tasks.valuetask 1.get_Result() at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask 1.get_result((at system.net.http.httpConnectionpool.WaitforCreatedConnectionAsync(valueTask 1 creationTask) at System.Threading.Tasks.ValueTask 1.get_result((
在 system.net.http.httpconnectionpool.sendwithretryasync(httprequestmessage 请求,布尔·dorequestauth,取消tocellationToken( at System.net.http.redirecthandler.sendasync(httpRequeStMessage 请求,取消tocellation concellationToken( system.net.http.httpclient.finishsendasensendasyncbuffered(task`1 sendtask, httprequestmessage请求,取消tokensource cts,布尔值 disposects(

我正在获取此错误当API调用来自Azure.My Chat Bot时,使用.NET Core 2.2/Bot Framework V4/c#开发了我的聊天bot。我的VM API使用端口80。

感谢您解决此错误的建议。

对于套接字禁止错误,您可以正确检查以下内容:

  • API端口80正在托管VM上听。
  • 该端口不使用其他应用程序,服务或进程。在Windows VM上,您可以在CMD中作为管理员帐户运行netstat -anbo来验证此问题。
  • 安全性或防火墙问题。如果您具有与此VM子网或VM网络接口关联的NSG,则需要添加一个入站规则,以允许从Web App Service中进行端口80。另外,如果您在VM内部的防火墙,则必须在VM防火墙上启用此入站端口。请参阅诊断虚拟机网络流量过滤器问题。
  • Azure应用程序服务中的访问限制。检查是否有任何IP规则限制是拒绝访问外部应用程序服务。

希望这可以帮助您。

最新更新