Cosmos DB connection configuration 'my-cosmos-unique-name_DOCUMENTDB' does not exist.

Ivan Alieksieienko 0 Reputation points
2025-01-30T19:48:58.1066667+00:00

Hi, trying to complete excercise Read data with input bindings. Hovewer encounter an error.

index.js:

module.exports = function (context, req) {

    console.log(JSON.stringify(context));
    console.log(JSON.stringify(req));
    
    var bookmark = context.bindings.bookmark

    if(bookmark){
        context.res = {
            body: { "url": bookmark.url },
            headers: {
                'Content-Type': 'application/json'
            }
        };
    }
    else {
        context.res = {
            status: 404,
            body : "No bookmarks found",
            headers: {
                'Content-Type': 'application/json'
            }
        };
    }

    context.done();
};

function.json:

{
    "bindings": [
      {
        "authLevel": "function",
        "type": "httpTrigger",
        "direction": "in",
        "name": "req",
        "methods": [
          "get",
          "post"
        ]
      },
      {
        "type": "http",
        "direction": "out",
        "name": "res"
      },
      {
        "name": "bookmark",
        "direction": "in",
        "type": "cosmosDB",
        "partitionKey": "{id}",
        "databaseName": "func-io-learn-db",
        "containerName": "Bookmarks",
        "connection": "my-cosmos-unique-name_DOCUMENTDB",
        "id": "{id}"
      }
    ]
  }

The error I'm getting:

Cosmos DB connection configuration 'my-cosmos-unique-name_DOCUMENTDB' does not exist. Make sure that it is a defined App Setting.

Operating System: Linux

Runtime version: 4.1036.3.3

Node 20 LTS

This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
2,021 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pradeep M 5,605 Reputation points Microsoft Vendor
    2025-01-31T04:40:44.75+00:00

    Hi Ivan Alieksieienko,

    Thank you for reaching out to Microsoft Q & A forum. 

    According to the documentation in the "Modify your function's JSON implementation code" section, step 2 advises replacing "your-database" with the name of your Azure Cosmos DB account. 

    For example, in the function.json file, update "connection": "your-database_DOCUMENTDB" to "connection": "Ivan Alieksieienko1234_DOCUMENTDB". The placeholders provided in the documentation are meant to be replaced with your actual database details. 

    Please refer to the attached screenshot for clarification. 

    310125_3

    Please feel free to contact us if you have any additional questions.     

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.  

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.