簡體   English   中英

綁定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

要選擇該屬性,您需要引用文檔DB Microsoft.Azure.WebJobs.Extensions.DocumentDB的NuGet包。 最后,我檢查了此NuGet軟件包是否仍在預發行版中,因此請確保在搜索軟件包時將其包括在內。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM