Azure Function App Cosmos DB触发器连接下降 [英] Azure Function App Cosmos DB trigger connection drop

查看:69
本文介绍了Azure Function App Cosmos DB触发器连接下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有cosmos DB触发器的Function应用程序,在本地运行时,行为很奇怪,因为我停止随机接收事件,就像与Lease集合的连接断开了一样.我收到一条错误消息,指出对Blob存储执行读取操作失败,但不确定是否与此相关.这是错误:

I am using a Function app with cosmos DB trigger, when running locally, the behavior is very strange as I stop receiving events randomly, like if the connection to the Lease collection drops. I am getting an error message that says a read operation fails to Blob storage, but not sure if this is related. Here's the error:

There was an error performing a read operation on the Blob Storage Secret Repository. 
Please ensure the 'AzureWebJobsStorage' connection string is valid

我正在使用以下代码运行功能应用程序: func host start --cors * --verbose

I am running the function app with this code: func host start --cors * --verbose

这是我可以在控制台中看到的CosmosDBOptions对象:

And here's the CosmosDBOptions object I can see in the console:

[2021-02-09T16:17:58.305Z] CosmosDBOptions
[2021-02-09T16:17:58.307Z] {
[2021-02-09T16:17:58.307Z]   "ConnectionMode": null,
[2021-02-09T16:17:58.308Z]   "Protocol": null,
[2021-02-09T16:17:58.309Z]   "LeaseOptions": {
[2021-02-09T16:17:58.310Z]     "CheckpointFrequency": {
[2021-02-09T16:17:58.310Z]       "ExplicitCheckpoint": false,
[2021-02-09T16:17:58.311Z]       "ProcessedDocumentCount": null,
[2021-02-09T16:17:58.311Z]       "TimeInterval": null
[2021-02-09T16:17:58.312Z]     },
[2021-02-09T16:17:58.313Z]     "FeedPollDelay": "00:00:05",
[2021-02-09T16:17:58.313Z]     "IsAutoCheckpointEnabled": true,
[2021-02-09T16:17:58.314Z]     "LeaseAcquireInterval": "00:00:13",
[2021-02-09T16:17:58.314Z]     "LeaseExpirationInterval": "00:01:00",
[2021-02-09T16:17:58.315Z]     "LeasePrefix": null,
[2021-02-09T16:17:58.316Z]     "LeaseRenewInterval": "00:00:17"
[2021-02-09T16:17:58.316Z]   }
[2021-02-09T16:17:58.323Z] }

和我的host.json文件:

and my host.json file:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  }
}

最后,由于我添加了共享文件夹(不确定是否相关但确实很烦人),因此开始出现该问题,删除租约集合可以暂时解决问题,但是这会花费大量时间,并且所有其他正在运行的功能都会中断,因为我清理了所有集合.

Finally, that issue started since I added a shared folder, not sure if it's related but it's really annoying, deleting leases collection solves temporary the problem but It costs a lot of time and all the other running functions break because I clean all the collection.

推荐答案

TLDR;使用CosmosDB仿真器进行本地开发可以解决此问题,因为您将没有两个指向同一个租约集合的函数.

有两个要点:

  1. 如果您在Azure上部署了一个Azure函数,并且在计算机上本地运行了相同租约配置以侦听同一受监视集合中的更改,则这些行为将充当同一部署的多个实例并且更改将传递给彼此,并且您可能会遇到事件丢失"的情况.在Azure中运行. https://docs.microsoft.com/zh-cn/azure/cosmos-db/troubleshoot-changefeed-functions#some-changes-are-missing-in-my-trigger .如果要让2个独立的Function侦听同一受监视集合中的更改,共享同一租约集合,则需要使用 LeaseCollectionPrefix 配置
  1. If you have one Azure Function deployed on Azure and one running locally in your machine with the same lease configuration listening for changes in the same monitored collection then these will behave as multiple instances of the same deployment and changes will be delivered to one or the other and you might experience "event loss" on the one running in Azure. This is documented in https://docs.microsoft.com/en-us/azure/cosmos-db/troubleshoot-changefeed-functions#some-changes-are-missing-in-my-trigger. If you want to have 2 independent Functions listening for changes in the same monitored collection, sharing the same lease collection, you need to use the LeaseCollectionPrefix configuration https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-create-multiple-cosmos-db-triggers
  2. The error you are seeing locally is potentially related to either not having the Azure Storage emulator running or not configuring the AzureWebJobsStorage configuration locally to use it. Azure Functions runtime (regardless of the Cosmos DB Trigger) requires a storage account. You can use UseDevelopmentStorage=true for the local storage emulator.

这篇关于Azure Function App Cosmos DB触发器连接下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆