簡體   English   中英

CosmosDBTrigger:未將對象引用設置為對象的實例

[英]CosmosDBTrigger: Object reference not set to an instance of an object

當我嘗試用CosmosDBTrigger執行新創建的azure函數時,我得到了cosmosdb觸發器函數的上述異常

調查信息

環境: Visual Studio 2017 15.3.5

引用的包:

  • Marvin.JsonPatch.Dynamic Version =“1.1.0”
  • Microsoft.Azure.DocumentDB版本=“1.17.0”
  • Microsoft.Azure.WebJobs Version =“2.1.0-beta4”
  • Microsoft.Azure.WebJobs.Extensions.DocumentDB Version =“1.1.0-beta4”
  • Microsoft.Azure.WebJobs.ServiceBus Version =“2.0.0”
  • Microsoft.NET.Sdk.Functions Version =“1.0.5”
  • Newtonsoft.Json版本=“10.0.3”
  • System.Configuration.ConfigurationManager版本=“4.4.0”

重現問題的步驟

提供重現問題所需的步驟:

  • 從Visual Studio創建新的Azure功能項目
  • 在創建.cs文件后添加一個函數(我找不到CosmosDB Binding的任何選項,所以我使用HttpTrigger創建),用我下面的代碼替換該文件。
  • 建立
  • 點擊F5

這是代碼示例

    public static class AddEventInEventStore
    {
        [FunctionName("AddEventInEventStore")]
        public static void Run([CosmosDBTrigger("db", "Items",
            ConnectionStringSetting = "AzureWebJobsDocumentDBConnectionString",
            LeaseCollectionName = "leases", LeaseDatabaseName = "db"
            )]
            IReadOnlyList<Document> changeList, TraceWriter log)
        {
            if (changeList != null && changeList.Count > 0)
            {
                log.Verbose("Documents modified " + changeList.Count);
                foreach (var change in changeList)
                {
                    log.Verbose("First document Id " + change.Id);
                }
            }

        }
    }

在此輸入圖像描述

更新Azure功能和Web作業工具(工具 - >擴展和更新)。

我可以看到你在1.0.0版本(控制台標題),而1.0.4已經可用。

暫無
暫無

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

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