question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cosmos DB trigger is not connecting to CosmosDB Emulator

See original GitHub issue

Hi Azure Functions Team, I have an Azure Functions App consisting of HttpTrigger Functions and CosmosDbTrigger Functions. Both kind of functions work fine and can connect against an actual CosmosDB instance. Unfortunately, when running against the CosmosDB emulator the CosmosDBTrigger Functions fail to connect against the CosmosDB emulator. The errors that I receive are of the following form:

[2022-01-15T18:17:06.601Z] Error indexing method 'Functions.feed'
[2022-01-15T18:17:06.601Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.feed'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create Collection Information for Article in database ##-db with lease leases in database ##-db : The SSL connection could not be established, see inner exception. System.Net.Http: The SSL connection could not be established, see inner exception. System.Private.CoreLib: The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch.

The settings of the app look like below:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=###;AccountKey=###;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "DATABASE_CONNECTION_STRING": "AccountEndpoint=https://##.###.###.###:8081/;AccountKey=<DEFAULT_PRIMARY_KEY>"
   }
}

Though, the remaining HttpTrigger functions can communicate with the CosmosDB emulator via the SDK’s CosmosClient. For this to work NODE_TLS_REJECT_UNAUTHORIZED=0 is set. But as the error looks like coming form the .NET functions tool itself not from any of our node application, it looks like this setting is not helping.

The CosmosDB emulator is setup as lined out in an answer to #1232 with the deviation that the local development is done on OSX, which is why the certificate import is different. And it looks like the imported certificate is ignored by .NET.

I believe a similar, if not same question was raised in #2024 was closed, but not solved. At least nothing I can find there helps me in resolving the described issues.

I’m not sure what else to try and would really appreciate any help at all 😃

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ealsurcommented, Jul 6, 2022

Do you build the Functions mostly on C#? I think that a solution like the second one (add a config as a boolean value) could be the one that tackles this problem across languages.

1reaction
macel94commented, Jul 2, 2022

Hi @ealsur @michaelpeng36

i’m developing a simple but complex enough example to really try to understand how developing in containers would really be for me and my team in next projects. I’m really finding it hard to solve this simple thing of triggering my azfunction

i’m using everything with the latest packages and everything is public beside the secret i was required to create(not my choice) to be able to use azure service bus.

if you want to repro this bug i believe i can help, if you want to take a look here: https://github.com/MACEL94/advanced-azure-microservices-with-dotnet-for-developers/tree/9-manage-to-make-everything-work-locally-with-just-a-docker-compose-up

everything is on linux as i’m trying to develop on codespaces

thank you anyway for your help

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot issues when using the Azure Cosmos DB ...
Use the tips in this article to help troubleshoot issues you encounter when installing or using the Azure Cosmos DB Emulator.
Read more >
How does Trigger work in Cosmos DB Emulator
1 Answer. Firstly,you need to know that Trigger in cosmos db is different from the azure function cosmos db trigger. It can't be...
Read more >
Create and deploy a Azure function triggered by ... - YouTube
In this video, you'll learn how to create a serverless function that's triggered by changes to data in Azure Cosmos DB, a globally ......
Read more >
Cosmos db functions. Also, please check the FireWall settings ...
When working with the Azure Functions Portal, create two separate Functions with a Cosmos DB Trigger and edit the function. After creating a...
Read more >
Getting Started with Azure Cosmos DB and Azure Functions
Azure Function Cosmos DB triggers under the hood make use of the Azure Cosmos DB change feed to know when to execute functions....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found