2017-08-16 104 views
1

在Azure上綁定Azure CosmosDB在本地運行的函數。需要使用此功能的任何配置?綁定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); 
      } 
     } 
    } 
} 

回答

1

是的,您的inputDocument參數需要配置。

您需要使用此屬性來指定Cosmos DB名稱和集合。

[DocumentDB("%DatabaseName%", "MyCollection")] IEnumerable<dynamic> inputDocuments 

要獲取該屬性,需要引用文檔DB Microsoft.Azure.WebJobs.Extensions.DocumentDB的NuGet包。最後,我檢查了這個NuGet包仍然處於預發佈階段,因此請確保在搜索包時包含該包。

enter image description here