Azure函数:CosmosDBTrigger在Visual Studio中未触发 [英] Azure Functions: CosmosDBTrigger not triggering in Visual Studio

查看:185
本文介绍了Azure函数:CosmosDBTrigger在Visual Studio中未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR :

TL;DR: This example is not working for me in VS2017.

我有一个Azure Cosmos数据库,并希望在其中添加或更新某些内容时触发一些逻辑.为此, CosmosDBTrigger 应该很棒.

I have an Azure Cosmos DB and want to fire some logic when something adds or updates there. For that, CosmosDBTrigger should be great.

教程演示了如何在Azure Portal中创建触发器,它对我有用.但是,在Visual Studio(目前最新的15.5.4版)中做同样的事情就不会.

Tutorial demonstrates creating trigger in Azure Portal and it works for me. However, doing just the same thing in Visual Studio (15.5.4, latest by now) does not.

我使用默认 Azure函数模板,预定义 Cosmos DB触发器和几乎默认代码:

I use the default Azure Functions template, predefined Cosmos DB trigger and nearly default code:

[FunctionName("TestTrigger")]
public static void Run(    
    [CosmosDBTrigger("Database", "Collection", ConnectionStringSetting = "myCosmosDB")]
    IReadOnlyList<Document> input,
    TraceWriter log)
    {
        log.Info("Documents modified " + input.Count);
        log.Info("First document Id " + input[0].Id);
    }

应用程序 运行 且没有错误 但没有任何反应 ,当我实际在数据库中进行操作时.因此,我无法调试事物并实际上实现一些必需的逻辑.

App runs without errors but nothing happens when I actually do stuff in the database. So I cannot debug things and actually implement some required logic.

连接字符串 ,并考虑了 .如果我故意犯规,则触发吐出运行时错误.

Connection string is specified in the local.settings.json and is considered. If I deliberately foul it, trigger spits runtime errors.

看起来连接字符串都连接到错误的数据库.但这恰好是我通过Azure Portal创建的触发器中具有复制粘贴的字符串.

It all looks like the connection string is to a wrong database. But it is exactly the one, copypasted, string I have in the trigger made via Azure Portal.

我在哪里可能出错?我还能检查什么?

推荐答案

根据您的评论,您同时为相同的集合和相同的租约集合同时运行门户和本地Apps.

Based on your comment, you were running both portal and local Apps at the same time for the same collection and the same lease collection.

这意味着两个App都在争夺收集处理的锁(租赁).在您的情况下,门户应用程序获胜并获得了租约,因此本地应用程序无所事事.

That means both Apps were competing to each other for locks (leases) on collection processing. The portal App won in your case, took the lease, so the local App was sitting doing nothing.

这篇关于Azure函数:CosmosDBTrigger在Visual Studio中未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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