Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 内部服务器错误500仅在Azure函数中有较大数据量的请求时发生_C#_Azure_Azure Functions - Fatal编程技术网

C# 内部服务器错误500仅在Azure函数中有较大数据量的请求时发生

C# 内部服务器错误500仅在Azure函数中有较大数据量的请求时发生,c#,azure,azure-functions,C#,Azure,Azure Functions,我有以下Azure功能: public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext context) { GetForumTopicsRespons

我有以下Azure功能:

    public static async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
        ILogger log, ExecutionContext context)
    {
        GetForumTopicsResponseModel forumTopicsModel = new GetForumTopicsResponseModel();
        try
        {
            HtpaaForumDB.HtpaaForumDB forumDB = new HtpaaForumDB.HtpaaForumDB(context);
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            GetForumTopicsTokenRequestModel reqMod = JsonConvert.DeserializeObject<GetForumTopicsTokenRequestModel>(requestBody);

            log.LogInformation("index:" + reqMod.IndexStart + " count:" + reqMod.Count);
            List<Topic> topics = await forumDB.GetTopics(reqMod.SortOrder, reqMod.IndexStart, reqMod.Count);
            log.LogInformation("Count:" + topics.Count);
            forumTopicsModel.Topics = topics;
            forumTopicsModel.StatusCode = HttpStatusCode.OK;
        }
        catch (Exception ex)
        {
            log.LogCritical(ex,"Error");
            forumTopicsModel.Message = ex.Message;
            forumTopicsModel.StatusCode = HttpStatusCode.BadRequest;
        }
        return new ObjectResult(forumTopicsModel);
上面的日志生成代码200和预期的数据集

2020-11-23T12:14:05.133 [Information] Executing 'GetForumTopics' (Reason='This function was programmatically called via the host APIs.', )
2020-11-23T12:14:05.962 [Information] index:0 count:20
2020-11-23T12:14:11.318 [Information] Count:10
2020-11-23T12:14:11.319 [Information] Executed 'GetForumTopics' (Succeeded, Duration=6220ms)
上面的日志生成代码500且没有数据(响应正文为空)


你知道我做错了什么吗?

原来这与我的EF模型中的循环依赖性有关。令人惊讶的是,它在我的单元测试中起了作用,但在JSON序列化时失败了。当你说“无数据”时,你的意思是没有500错误的响应体,还是没有得到预期的数据?我肯定会检查是否有任何类型的响应体,因为它可能会为您提供错误的线索。没有数据,我的意思是响应体是空的。
2020-11-23T12:14:05.133 [Information] Executing 'GetForumTopics' (Reason='This function was programmatically called via the host APIs.', )
2020-11-23T12:14:05.962 [Information] index:0 count:20
2020-11-23T12:14:11.318 [Information] Count:10
2020-11-23T12:14:11.319 [Information] Executed 'GetForumTopics' (Succeeded, Duration=6220ms)