Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绑定CosmosDB局部函数_C#_Azure_Azure Functions_Azure Cosmosdb - Fatal编程技术网

C# 绑定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")]

在本地运行的Azure函数上绑定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);
            }
        }
    }
}
使用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
要获取该属性,您需要引用文档DB
Microsoft.Azure.WebJobs.Extensions.DocumentDB
的NuGet包。上一次我检查这个NuGet软件包仍然是预发布的,所以确保在搜索软件包时包含它