Azure golang函数未在正文中接收请求负载

Azure golang函数未在正文中接收请求负载,azure,go,azure-functions,azure-function-app,azure-functions-runtime,Azure,Go,Azure Functions,Azure Function App,Azure Functions Runtime,我已经在Go中创建了一个Azure函数。该功能在具有GET和POST请求的本地计算机中正常工作。发布时,通过POST发送的请求负载在请求对象中不可用。 这是我的密码: # Main function mux := http.NewServeMux() mux.HandleFunc("/hello", helloWorld) logrus.Fatal(http.ListenAndServe(":"+httpInvokerPort, mux)) # hell

我已经在Go中创建了一个Azure函数。该功能在具有GET和POST请求的本地计算机中正常工作。发布时,通过POST发送的请求负载在请求对象中不可用。 这是我的密码:

# Main function
mux := http.NewServeMux()
mux.HandleFunc("/hello", helloWorld)
logrus.Fatal(http.ListenAndServe(":"+httpInvokerPort, mux))

# helloWorld function
func helloWorld(w http.ResponseWriter, r *http.Request) {
    logrus.Info("hello: inside helloWorld")

    bodyBuffer, err := ioutil.ReadAll(r.Body)
    if err != nil {
        logrus.Info("error while reading:" + err.Error())
        w.Write([]byte("GO: error in reading request body"))
    } else {
        logrus.Info("body : " + string(bodyBuffer))

        w.Write([]byte("GO: return hello"))
    }
}

部署后,我使用以下JSON主体调用POST api请求:

{ 
    "a": "b"
}
在日志中,我看到:

time=“2020-07-31T01:14:11Z”level=info msg=“body:”

function.json:

{
    "bindings": [
        {
            "authLevel": "anonymous",
            "type": "httpTrigger",
            "direction": "in",
            "name": "req",
            "methods": ["get", "post"]
        },
        {
            "type": "http",
            "direction": "out",
            "name": "res"
        }
    ]
}
我的代码托管在这里:


有没有关于如何调试的建议?

这是基于Windows操作系统的功能应用程序的问题。当我将操作系统类型更新为Linux时,我开始接收请求负载

以下是我的functionapp创建命令:

az functionapp create --resource-group hellogogrplinux --os-type Linux --consumption-plan-location eastus --runtime node --runtime-version 10 --functions-version 3 --name hellogoapplinux --storage-account hellogostglinux
这是我的更新日志:

time="2020-08-06T03:21:38Z" level=info msg="body : {\n \"a\": \"b\"\n}"
这是Azure功能主机上的已知问题,现已解决。本周将作为运行时版本3.0.14251的一部分推出


关于这个github问题,有更多的细节:

formatRequest做什么?为什么在阅读请求正文时忽略错误?@Volker我已经更新了代码以删除formatRequest。formatRequest函数用于打印请求标头值。即使在更新之后,我也会看到相同的日志条目。我没有看到任何错误日志。@Volker我也更新了错误处理代码