如何修复 .Net Azure Function App 中的 'Operation is not valid due to the current state of the object' 错误?

How to fix 'Operation is not valid due to the current state of the object' error in .Net Azure Function App?

我有一个由 SQL 连接器 "When an item is created V2" 触发的逻辑应用程序执行的 .NET Azure 函数。该函数从多个 API 收集数据并将数据插入到 SQL 数据库中。该函数适用于单个记录,但是,当将一批记录插入 SQL table 触发该函数时,该函数将中断并出现以下错误:

Operation is not valid due to the current state of the object

根据 Stack Overflow 上的多个线程(即 'Operation is not valid due to the current state of the object' error during postback ),要解决该问题,应按以下方式配置 Web 配置文件:

<appSettings>
     <add key="aspnet:MaxHttpCollectionKeys" value="2001" />
</appSettings>

有什么方法可以更改 Azure Function App 的 web.config 文件吗?我会在哪里找到它?还是我应该自己创建它?对于如何解决此问题,您还有其他想法吗?

您可以在 azure 函数的 host.json 中使用 "maxOutstandingRequests" 和 "maxConcurrentRequests" 的属性进行设置(转到您的函数应用程序 --> 概述 --> 函数应用程序settings --> host.json), 请参考这个tutorial

希望对您的问题有所帮助。