C# 绑定CosmosDB局部函数
在本地运行的Azure函数上绑定Azure CosmosDB。使用此功能需要任何配置吗C# 绑定CosmosDB局部函数,c#,azure,azure-functions,azure-cosmosdb,C#,Azure,Azure Functions,Azure Cosmosdb,在本地运行的Azure函数上绑定Azure CosmosDB。使用此功能需要任何配置吗 using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Host; using System.Collections.Generic; namespace CDPCompare { public static class CallWS { [FunctionName("TimerTriggerCSharp")]
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);
}
}
}
}
使用Microsoft.Azure.WebJobs;
使用Microsoft.Azure.WebJobs.Host;
使用System.Collections.Generic;
命名空间CDPCompare
{
公共静态类CallWS
{
[函数名(“TimerTriggerCSharp”)]
公共静态无效运行([TimerTrigger(“0*/5****”)TimerInfo myTimer、TraceWriter日志、IEnumerable inputDocument)
{
foreach(inputDocument中的var项)
{
日志信息(项目);
}
}
}
}
是,您的inputDocument
参数需要配置
您需要使用此属性来指定Cosmos DB名称和集合
[DocumentDB("%DatabaseName%", "MyCollection")] IEnumerable<dynamic> inputDocuments
[DocumentDB(“%DatabaseName%”,“MyCollection”)]IEnumerable inputDocuments
要获取该属性,您需要引用文档DBMicrosoft.Azure.WebJobs.Extensions.DocumentDB
的NuGet包。上一次我检查这个NuGet软件包仍然是预发布的,所以确保在搜索软件包时包含它