首页 > 其他分享 >【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward

【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward

时间:2022-10-24 11:00:39浏览次数:61  
标签:Function status code HTTP 代码 forward Azure

问题描述

使用 Azure Funciton App,在本地运行完全成功的Python代码,发布到Azure Function就出现了500  Internal Server Error. 而且错误消息也是莫名的 Failed to forward request to http://169.254.130.x。

2022-07-11T11:46:01.646550271Z Failed to forward request to http://169.254.130.7.

Encountered a System.Net.Http.HttpRequestException exception after 562.442ms with message: Received an invalid status line: 'HTTP/1.1 1 '..

Check application logs to verify the application is properly handling HTTP traffic.

问题解决

在Azure Function的Test/Run页面,根据在代码中添加的日志标签,可以准确的定位到错误发生在29号代码。

【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward_App Service

 

 第29行代码为:

return func.HttpResponse(f"Logic Hello, {dresult}. This HTTP triggered function executed successfully.",status_code=1)

与默认生成的Python Function模板代码的区别只有 status_code 设置为了1. 默认的没有指定。

return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")

所以非常怀疑就是这里的问题. 查看源码,默认值就是200, 但是这里也没有说不允许设置为1啊!

【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward_python_02

 

但是为了验证是这里的问题。修改代码,设置 status_code 为200后,再次部署到Azure Function中。 经过测试,奇妙的500错误消息。

【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward_python_03

如此可以成功判断:

 

至此,问题解决。关于为什么status_code不能设置为1,并且去请求http://169.254.130.x 得地址,因为无法在云环境中Debug而无从得出结论。

 

 

【如以后有更多的资料后,在进行分析。。。】

 

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



标签:Function,status,code,HTTP,代码,forward,Azure
From: https://blog.51cto.com/u_13773780/5788879

相关文章

  • ABC246D 2-variable Function 题解
    ABC246D2-variableFunctionSolution目录ABC246D2-variableFunctionSolution更好的阅读体验戳此进入题面SolutionCodeUPD更好的阅读体验戳此进入题面存在函数$f......
  • create-function函数代码注入
    creat_function()代码注入creat_function函数根据传递的参数创建匿名函数,并为其返回唯一名称。语法:create_function(string$args,string$code)string$args声明的函......
  • (转)MySQL 创建函数报错 This function has none of DETERMINISTIC, NO SQL, or READS
    原文地址:https://www.cnblogs.com/miracle-luna/p/14760051.html 在MySQL中创建函数时,报错如下:ThisfunctionhasnoneofDETERMINISTIC,NOSQL,orREADSSQLDATA......
  • drools_07_macro_functions
    delete()和retract()宏函数delete()用于在ruleRHS中将对象从工作内存中删除,retract()函数有同样的作用,不过已经被标记为废弃状态.insert()宏函数insert()用于......
  • JSP include 和 forward的区别
    <jsp:include>动作元素用来包含静态和动态的文件。该动作把指定文件插入正在生成的页面。语法格式如下:<jsp:includepage="相对URL地址"flush="true"/>include指......
  • [RxJS] Extract common operator logic into standalone function
    /**From*/click$.pipe(mergeMapTo(throwError({status:400,message:'Servererror'}).pipe(retryWhen(attempts=>{returnatt......
  • [Typescript] Tips: Use assertion functions inside classes
    Youcandosomereally,reallyneatstuffwithassertionfunctionsinsideclasses.Here,weassertthattheuserisloggedinandgetproperinferenceontheu......
  • [COMP2121] Discrete Mathematics - Question on Function
    DescriptionLet$A$beafiniteset,andlet$F(A)$bethesetofallfunctionsfrom$A$toitself.Considertherelation$R$on$F(A)$definedby$fRg$ifand......
  • Prefix Function Queries
    传送门感觉字符串只会hash了。这里提几点易错点:①字符串能不用string就不用。反正这道题因为string的size(不能正常清空)和读入Wa飞了②hash都写双模数。......
  • MySQL 函数 function
    函数内置函数function字符串--常用函数串操作函数set@str='hello中国';select@str,length(@str),char_length(@str),character_length(@str),reverse(@str);......