在本地运行的 Azure Functions 上绑定(bind) Azure CosmosDB。使用此功能需要任何配置吗?
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using System.Collections.Generic;
namespace CDPCompare
{
public static class CallWS
{
[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log, IEnumerable<dynamic> inputDocument)
{
foreach(var item in inputDocument)
{
log.Info(item);
}
}
}
}
最佳答案
是的,您的 inputDocument
参数需要配置。
您需要使用此属性来指定 Cosmos DB 名称和集合。
[DocumentDB("%DatabaseName%", "MyCollection")] IEnumerable<dynamic> inputDocuments
要获取该属性,您需要引用文档数据库 Microsoft.Azure.WebJobs.Extensions.DocumentDB
的 NuGet 包。最后我检查了这个 NuGet 包仍处于预发布状态,因此请确保在搜索该包时包含该包。
关于c# - 绑定(bind) CosmosDB 本地函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45722853/