none
CosmosDb Trigger: The listener for function 'FunctionName' was unable to start. RRS feed

  • Question

  • Hi forum,

    Started getting this error only locally when I try to debug my azure function:

    The listener for function 'MyFunctionName' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.

    This function was working perfectly fine before I got a new machine but code is exactly the same.  I am using version 1.0.12 of the Azure.Functions.CLI.  What am I missing?

    Thanks for any assistance.


    • Edited by kumal Monday, July 16, 2018 9:32 PM
    Monday, July 16, 2018 9:32 PM

All replies

  • If you are running a new machine I would think the issue would be related to a missing SDK or dependency. 

    I would make sure that the CosmosDB bindings are installed and up to date along with the webjobs mentioned in the below link:

    https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb#packages---functions-1x

    You also would want to make sure your Visual Studio is updated and all the extensions are up to date. 

    Feel free to share you function code here as well and I can test it out so we can compare

    Monday, July 16, 2018 11:31 PM
    Moderator
  • Thanks Micah for responding.

    That's my suspicion too, that i am missing something.  I did notice an exclamation next to the Microsoft.Azure.WebJobs.Extensions.DocumentDB package.  Tried to reinstall it and it was successful but still exclamation.  I did check Extensions and updates, ran updates, still the error.  The same code works perfectly fine on my old machine, and my teammate's machine.  It has to be my environment, where else should I look?

    Note: You might be wondering why beta, well, that's the only version we could get it to work.  

    

    Tuesday, July 17, 2018 5:40 PM
  • Double check the Output window in VS, there is something wrong with your package dependencies.

    Are you manually adding the DocumentDB SDK Nuget package? If so, please remove it.

    Tuesday, July 17, 2018 11:48 PM
  • Thanks for the response, I use nuget console in VS to install the package.   What should I look at in the output window?  There is no error that I can see besides what I mentioned, here it is again:

    The listener for function 'MyFunctionName' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.



    • Edited by kumal Wednesday, July 18, 2018 4:12 PM
    Wednesday, July 18, 2018 3:41 PM
  • I think I see what the issue is, here is the error in the output window:

    DocDBTrace Information: 0 : Could not get quorum number of responses. ValidResponsesReceived: 0 ResponsesExpected: 2, ResolvedAddressCount: 11, ResponsesString: 
    DocDBTrace Warning: 0 : QuorumNotSelected: Quorum could not be selected with read quorum of 2
    DocDBTrace Information: 0 : GetOpenConnection failed: RID: dbs/myDatabase, ResourceType Database, Op: (operationType: Read, resourceType: Database), Address: rntbd://myActualIP:10251/apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, Exception: Microsoft.Azure.Documents.GoneException: Message: The requested resource is no longer available at the server.
    ActivityId: 60206b69-8e8f-45ca-843a-89366b3040aa, Request URI: rntbd://myActualIP:10251/apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/ ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
       at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
       at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
       at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
       at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Microsoft.Azure.Documents.RntbdConnection.<PerformHandshakes>d__20.MoveNext()
       --- End of inner exception stack trace ---
       at Microsoft.Azure.Documents.RntbdConnection.<PerformHandshakes>d__20.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

    The port of my local cosmosDB and the db I configured points to 127.0.0.1:8081, but error shows it is trying to use port 10251 and with my actual IP.  Why is it looking for my actual IP and 10251?  I tried searching for 10251 in my solution and didnt find any instance of it.

    Here is my function code:

    [FunctionName("MyFunctionName")]
            public static void Run([CosmosDBTrigger(
                databaseName: "MyDatabase",
                collectionName: "MyCollection",
                ConnectionStringSetting = "MyCosmosDB",
                LeaseCollectionName = "leases")]

    And here is the configuration in local.settings.json:

    "MyCosmosDB": "AccountEndpoint=https://localhost:8081/;AccountKey=someaccountkeyString

    What am I missing?

    Wednesday, July 18, 2018 5:16 PM
  • Ok, this is weird, after many tries, this seems to have been fixed.  Found a google post and followed what was suggested, so I right clicked on the cosmosdb icon in systray, selected reset data, rerun the function, no error.

    What gives?!?  This is so annoying, spent two days trying to figure out what is wrong and I still dont know what the exact issue was.

    Anyways, hope this helps someone.  And thanks to everyone responded.

    Wednesday, July 18, 2018 6:25 PM
  • can you share the post you found that helped?
    Wednesday, July 18, 2018 6:52 PM
    Moderator
  • Sure, it is the last comment:

    https://github.com/Azure/azure-documentdb-dotnet/issues/408

    Wednesday, July 18, 2018 6:53 PM
  • Still is weird that you had the warning in the nuget packages, that is independent of whether you are connecting to the Local Cosmos DB emulator or to a live Cosmos DB account in Azure.

    If there is a warning sign in VS, in the Output or Errors/Warning window, there should be something that explains what is happening.

    Sometimes when you are working with a pre-compiled Function, users add the DocumentDB SDK package manually, the Functions packages already have the DocumentDB SDK dependency, and there might be a version conflict, so removing the DocumentDB SDK that was manually added to the project solves the conflict.

    Wednesday, July 18, 2018 7:13 PM
  • I have heard about that, where the SDK is already loaded with functions, and can cause conflicts and unexplained issues.  So are you saying i should remove this nuget package:

    Microsoft.Azure.WebJobs.Extensions.DocumentDB

    To be honest, I dont really want to touch the solution now lol after all the frustrations from the past two days.  But I am curious to know.  Also as you said, there are still those yellow exclamations next to my nuget packages.

    Wednesday, July 18, 2018 7:18 PM
  • On the contrary, that is the package you want to keep :)

    I would remove the DocumentDB SDK package (Microsoft.Azure.DocumentDB) if you run into errors when the Trigger is fired. There is a known one where a message appears saying that it can only bind to IReadOnlyList<Document> or JArray.

    If it's working, then don't worry about it. But if you run into any issues when it's triggering, post back the error that is appearing.

    Wednesday, July 18, 2018 7:21 PM
  • I see, thanks for the clarification.  I see Microsoft.Azure.DocumentDB being under Microsoft.Azure.WebJobs.Extensions.DocumentDB so I thought the whole package should be removed.  But anyways, not going to touch anything now.  But will keep an eye out for any other related errors.   Thanks again.
    Wednesday, July 18, 2018 7:25 PM