简体   繁体   English

Cosmos db 更改提要触发器在 function 进入睡眠状态后未触发

[英]Cosmos db change feed trigger not firing after function goes to sleep

I have a function that works fine locally but is not triggered in Azure unless the function is "awake".我有一个 function,它在本地工作正常,但不会在 Azure 中触发,除非 function 处于“唤醒”状态。 The function just copies items from one container to another, with the primary key and id columns swapped (as an eventually-consistent secondary index). function 只是将项目从一个容器复制到另一个容器,交换主键和 id 列(作为最终一致的二级索引)。 There are two functions in this app, both of which are Cosmos triggers (different source containers and lease prefixes);这个app中有两个函数,都是Cosmos触发器(不同的源容器和租用前缀); all my other functions are in other apps.我所有的其他功能都在其他应用程序中。

The function is in a Linux consumption plan, deployed via the GitHub Action Azure/functions-action@v1 , which uses zipdeploy, which should be syncing triggers . function 在 Linux 消费计划中,通过GitHub Action Azure/functions-action@v1部署,使用 zipdeploy, 应该是 syncing triggers There are no other functions listening on that container (local instances listen to the emulator), and this function has a unique lease prefix anyway.没有其他函数在该容器上侦听(本地实例侦听模拟器),而且这个 function 无论如何都有一个唯一的租用前缀。

If I view the function app in the portal (even just the Overview page), the function "wakes up" and processes all the Cosmos DB items just fine.如果我在门户中查看 function 应用程序(即使只是“概述”页面),function“醒来”并处理所有 Cosmos DB 项目就好了。 If I then close the Overview page, wait ~30 minutes, and change an item in the watched container, the function does not fire.如果我随后关闭概览页面,等待约 30 分钟,并更改监视容器中的项目,则 function 不会触发。 Nothing goes into the Azure Monitor logs and the corresponding item does not change in the destination container. Azure 监视器日志中没有任何内容,目标容器中的相应项目也没有更改。 I can wait several (10) minutes and refresh, and there is still nothing in the logs or the destination container.我可以等待几 (10) 分钟并刷新,但日志或目标容器中仍然没有任何内容。 Then when I re-open the Overview page, the function immediately triggers, and the item in the destination container is updated pretty much immediately;然后,当我重新打开概览页面时,function 立即触发,目标容器中的项目几乎立即更新; the Azure Monitor logs show up 2-3 minutes later (a normal amount of lag). Azure 监视器日志在 2-3 分钟后显示(正常延迟量)。 This behavior is 100% repeatable.此行为是 100% 可重复的。

I've checked all the troubleshooting suggestions multiple times, but I don't see anything that would help.我已多次检查所有故障排除建议,但没有发现任何有用的信息。

How do I get this function to trigger without me observing it in the portal?如何让这个 function 在我不在门户中观察它的情况下触发?

Turns out I had my connection strings wrong.原来我的连接字符串错了。 I had the CosmosDb trigger connection string in ConnectionStrings when it was supposed to be in AppSettings .当它应该在AppSettings中时,我在ConnectionStrings中有 CosmosDb 触发器连接字符串。

The function would actually work locally (and if it was already running in the cloud) because the bindings were looking in both places: AppSettings where it was supposed to be, and falling back to ConnectionStrings . function 实际上可以在本地工作(如果它已经在云中运行),因为绑定在两个地方查找: AppSettings它应该在的地方,然后回退到ConnectionStrings However, when the function "slept", the Azure scale controller was only watching AppSettings , so that's why it would never wake up.然而,当 function“睡着”时,Azure 秤 controller 只在看AppSettings ,所以这就是它永远不会醒来的原因。

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

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