Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.33k stars 437 forks source link

Cannot run CosmosDB trigger function locally #569

Closed jdneo closed 6 years ago

jdneo commented 6 years ago

Here is the logs:

[7/4/2018 9:13:33 AM] Reading host configuration file 'D:\work\Java\maven\Azure-Functions-Java-Samples\CosmosDBTrigger\project\target\azure-functions\azure-functions-name-cas-csc8\host.json'
[7/4/2018 9:13:33 AM] Host configuration file read:
[7/4/2018 9:13:33 AM] {}
[7/4/2018 9:13:33 AM] Starting Host (HostId=shechepc-1694341971, InstanceId=13ff8f45-3118-42d9-9dd8-116c7b8272c0, Version=2.0.11888.0, ProcessId=45756, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[7/4/2018 9:13:33 AM] 'FUNCTIONS_WORKER_RUNTIME' is specified, only 'java' will be enabled
[7/4/2018 9:13:33 AM] Loading custom extension 'CosmosDBConfiguration'
[7/4/2018 9:13:33 AM] Loaded custom extension: CosmosDBConfiguration from 'D:\work\Java\maven\Azure-Functions-Java-Samples\CosmosDBTrigger\project\target\azure-functions\azure-functions-name-cas-csc8\bin\Microsoft.Azure.WebJobs.Extensions.CosmosDB.dll'
[7/4/2018 9:13:33 AM] Start Process: C:\Program Files\Java\jdk1.8.0_172\bin\java  -jar "C:\Users\sheche\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\java\azure-functions-java-worker.jar" --host 127.0.0.1 --port 53590 --workerId 58a30f94-9465-4412-9513-3a3fe5f82ebc --requestId 954320f2-c0be-4b84-b2ff-cb5f65a0f275 --grpcMaxMessageLength 134217728
[7/4/2018 9:13:33 AM] Generating 1 job function(s)
[7/4/2018 9:13:34 AM] Microsoft Azure Functions Java Runtime [build 1.1.0-beta6]
[7/4/2018 9:13:34 AM] [INFO] {MessageHandler.handle}: Message generated by "StartStream.Builder"
[7/4/2018 9:13:35 AM] Worker initialized
[7/4/2018 9:13:35 AM] "CosmosDb" loaded (ID: bb1ac841-9668-40b9-a274-f215a91831cf, Reflection: "D:\work\Java\maven\Azure-Functions-Java-Samples\CosmosDBTrigger\project\target\azure-functions\azure-functions-name-cas-csc8\cosmos-db-sample-1.0-SNAPSHOT.jar"::"com.azure.functions.samples.CosmosDb.cosmosDBHandler")
[7/4/2018 9:13:36 AM] Found the following functions:
[7/4/2018 9:13:36 AM] Host.Functions.CosmosDb
[7/4/2018 9:13:36 AM]
[7/4/2018 9:13:36 AM] Host initialized (2642ms)
Listening on http://0.0.0.0:7071/
Hit CTRL-C to exit...
[7/4/2018 9:13:36 AM] Host lock lease acquired by instance ID '000000000000000000000000ED91E885'.
[7/4/2018 9:13:39 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:13:39 AM] The listener for function 'Functions.CosmosDb' was unable to start. System.Private.CoreLib: One or more errors occurred. (Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)). Microsoft.Azure.DocumentDB.Core: Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E).
[7/4/2018 9:13:39 AM] The listener for function 'Functions.CosmosDb' was unable to start. System.Private.CoreLib: One or more errors occurred. (Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)). Microsoft.Azure.DocumentDB.Core: Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E).
[7/4/2018 9:13:39 AM]
[7/4/2018 9:13:39 AM] Host started (6395ms)
[7/4/2018 9:13:39 AM] Job host started
[7/4/2018 9:13:39 AM] The following 1 functions are in error:
[7/4/2018 9:13:39 AM] CosmosDb: The listener for function 'Functions.CosmosDb' was unable to start. System.Private.CoreLib: One or more errors occurred. (Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)). Microsoft.Azure.DocumentDB.Core: Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E).
[7/4/2018 9:13:39 AM]
[7/4/2018 9:13:39 AM]
[7/4/2018 9:13:41 AM] Retrying to start listener for function 'Functions.CosmosDb' (Attempt 1)
[7/4/2018 9:13:41 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:13:41 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:13:41 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:13:42 AM]
[7/4/2018 9:13:45 AM] Retrying to start listener for function 'Functions.CosmosDb' (Attempt 2)
[7/4/2018 9:13:45 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:13:45 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:13:45 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:13:45 AM]
[7/4/2018 9:13:52 AM] Retrying to start listener for function 'Functions.CosmosDb' (Attempt 3)
[7/4/2018 9:13:52 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:13:52 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:13:52 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:13:52 AM]
[7/4/2018 9:14:02 AM] Retrying to start listener for function 'Functions.CosmosDb' (Attempt 4)
[7/4/2018 9:14:02 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:14:02 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:14:02 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:14:02 AM]
[7/4/2018 9:14:19 AM] Retrying to start listener for function 'Functions.CosmosDb' (Attempt 5)
[7/4/2018 9:14:19 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:14:19 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:14:19 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:14:19 AM]
[7/4/2018 9:14:54 AM] Retrying to start listener for function 'Functions.CosmosDb' (Attempt 6)
[7/4/2018 9:14:54 AM] The listener for function 'Functions.CosmosDb' was unable to start.
[7/4/2018 9:14:54 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:14:54 AM] The listener for function 'Functions.CosmosDb' was unable to start. Microsoft.Azure.Documents.ChangeFeedProcessor: Object reference not set to an instance of an object.
[7/4/2018 9:14:54 AM]
anthonychu commented 6 years ago

Try running this to get a later version of Microsoft.Azure.DocumentDB.Core which will restore the interop dll properly:

func extensions install -p Microsoft.Azure.DocumentDB.Core -v 2.0.0-preview

More details here: https://github.com/Azure-Samples/functions-serverless-chat-app-tutorial/issues/1

jdneo commented 6 years ago

@anthonychu Thank you for reaching out. But I'm still getting this error after running the command.

mariomeyrelles commented 6 years ago

In my case I was running node and not java.

I had to be absolutely sure that the indirect dependency, Microsoft.Azure.Documents.ServiceInterop.dll is present on the \bin folder. Adding Microsoft.Azure.DocumentDB.Core in my case:

Another important thing: I ran this sample using real CosmosDB database and collection. I'm not sure if the emulator is good enough for this kind of scenarios.

The image below shows how things are set on my sample:

image

ahmelsayed commented 6 years ago

This issue was moved to Azure/azure-webjobs-sdk-extensions#430