绑定 CosmosDB 本地函数
Bind CosmosDB Local Function
在 Azure Functions 运行 本地绑定 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
要获取该属性,您需要引用文档数据库的 NuGet 包 Microsoft.Azure.WebJobs.Extensions.DocumentDB
。最后我检查了这个 NuGet 包仍处于预发布阶段,所以确保在搜索包时包含它。
在 Azure Functions 运行 本地绑定 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
要获取该属性,您需要引用文档数据库的 NuGet 包 Microsoft.Azure.WebJobs.Extensions.DocumentDB
。最后我检查了这个 NuGet 包仍处于预发布阶段,所以确保在搜索包时包含它。