繁体   English   中英

如何使用Cosmos DB触发器从Azure函数中的Azure Cosmos DB中断中恢复

[英]How to recover from Azure Cosmos DB Outage in Azure Function with Cosmos DB Trigger

带有Cosmos DB触发器的Azure函数(v1)如何从Cosmos DB中断中恢复? 这应该自动发生还是需要重启功能应用程序?

在我们的方案中,Cosmos DB不可用,因为达到了订阅支出限制。 取消支出限制后,Cosmos DB再次可用,并且通过输出绑定写入Cosmos DB的函数成功。

但是,通过CosmosDB触发器连接到Cosmos DB的函数无法从此中断中恢复,并不断抛出以下异常:

Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'xxx' was unable to start. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedEventHost.<StartAsync>d__77.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedEventHost.<RegisterObserverFactoryAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Extensions.DocumentDB.CosmosDBTriggerListener.<StartAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.<StartAsync>d__14.MoveNext()
   --- End of inner exception stack trace ---

重新启动Function App之后,Cosmos DB触发器再次工作。

我想,当Cosmos DB由于其他原因遭受中断时,也会发生这种情况。

为了使我们的系统能够抵御Cosmos DB的临时中断,我们如何才能使CosmosDB触发器返回到操作状态? 如果出现错误,我们是否必须重新启动功能应用程序?或者有更好的方法吗?

这是由于Azure Functions运行时和Cosmos DB触发器中的重试机制存在问题。

运行时不断尝试重新初始化触发器,以指数方式退缩,但是在这种特定情况下(超出支出限额),它遇到了问题。 Github问题对此进行了跟踪。

对此修复程序已合并 ,应该包含在运行时的下一发行版中。

修复程序到位后,如果该帐户再次可用,则无需重新启动Function App。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM