【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward request to http://169.254.130.x

简介: 【Azure 应用服务】Azure Function HTTP Trigger 遇见奇妙的500 Internal Server Error: Failed to forward request to http://169.254.130.x

问题描述

使用 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号代码。

 

第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啊!

 

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

如此可以成功判断: 是由于status_code为1导致了Failed to forward request to http://169.254.130.x的异常。

 

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

 

 

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

相关文章
|
20天前
|
JavaScript Linux 数据中心
【Azure Function App】解决Function App For Container 遇见ServiceUnavailable的异常
【Azure Function App】解决Function App For Container 遇见ServiceUnavailable的异常
【Azure Function App】解决Function App For Container 遇见ServiceUnavailable的异常
|
20天前
|
Java 容器
【Azure Function App】Java Function在运行中遇见内存不足的错误
【Azure Function App】Java Function在运行中遇见内存不足的错误
|
20天前
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
|
20天前
[Azure Developer]把Azure Function中ILogger对象静态化为静态方法提供日志记录
[Azure Developer]把Azure Function中ILogger对象静态化为静态方法提供日志记录
|
20天前
【Azure Function App】本地运行的Function发布到Azure上无法运行的错误分析
【Azure Function App】本地运行的Function发布到Azure上无法运行的错误分析
|
20天前
【Azure Function App】遇见无法加载Microsoft.Azure.WebJobs.ParameterBindingData的问题
【Azure Function App】遇见无法加载Microsoft.Azure.WebJobs.ParameterBindingData的问题
|
20天前
【Azure Function】Azure Function中的Timer Trigger无法自动触发问题
【Azure Function】Azure Function中的Timer Trigger无法自动触发问题
|
20天前
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢?
|
20天前
【Azure Function】在Function执行中遇见Timeout错误
【Azure Function】在Function执行中遇见Timeout错误
|
20天前
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错

热门文章

最新文章