0

I'm experiencing an issue with an Azure Function App named 'fa-store-ticket' that contains a function called 'CosmosTrigger1'. The runtime stack is Node ~18, running on Windows, and the operating mode is set to Consumption.

Here's the function.json configuration:

{
    "bindings": [
        {
            "type": "cosmosDBTrigger",
            "name": "documents",
            "direction": "in",
            "leaseCollectionName": "leasesStoreTickets",
            "connectionStringSetting": "database-mdb_DOCUMENTDB",
            "databaseName": "STORE_POS",
            "collectionName": "storeTickets",
            "createLeaseCollectionIfNotExists": true
        }
    ]
}

And here's the function's index.js:

module.exports = async function (context, documents) {
    context.log('Prueba');
}

When running the function, I'm getting the following logs in Application Insights:

7/27/2023, 11:46:31.821 PM
The listener for function 'Functions.CosmosTrigger1' was unable to start.
7/27/2023, 11:46:31.730 PM
Retrying to start listener for function 'Functions.CosmosTrigger1' (Attempt 2)
7/27/2023, 11:46:29.572 PM
Host lock lease acquired by instance ID '{websiteInstanceId}'.
7/27/2023, 11:46:27.934 PM
The listener for function 'Functions.CosmosTrigger1' was unable to start.
7/27/2023, 11:46:27.772 PM
Retrying to start listener for function 'Functions.CosmosTrigger1' (Attempt 1)
7/27/2023, 11:46:25.839 PM
Host Status: { "id": "fa-store-ticket", "state": "Running", "version": "4.23.0.20886", "versionDetails": "4.23.0+eeacf7e92eafab538714da022f610810a252f36d", "platformVersion": "100.0.7.442", "instanceId": "ffb36bd0b4e8606c3d02b60790248fe9ad51747a9ac80fb7cc625589efab50b4", "computerName": "10-30-0-23", "processUptime": 252763, "functionAppContentEditingState": "Unknown", "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "3.24.0" } }
7/27/2023, 11:46:25.774 PM
Job host started

The error message I'm receiving is "The listener for function 'Functions.CosmosTrigger1' was unable to start.". The system also retries to start the listener without success.

I've checked the Cosmos DB connection string, and it seems to be correct. Furthermore, the Cosmos DB database is operating normally.

Does anyone have an idea about what might be causing this issue or where I should look next to troubleshoot it? Any assistance would be greatly appreciated.

Thanks in advance!

Daniel Vera
  • 77
  • 1
  • 10

2 Answers2

1

The listener for function 'Functions.CosmosTrigger1' was unable to start.

  • Mostly, the above error occurs when the configuration in your function.json doesn't match with the cosmos DB environment.

I also tried and faced the same error which you got.

enter image description here

  • After the deployment to function app, I just added the connectionStringSetting value balacosmos_DOCUMENTB to the Application settings in my deployed function app.

enter image description here

Added name as connectionStringSetting and value as cosmos DB account connection string and save.

  • Open Advance tools<Go<Path_to_your_application the run npm start

enter image description here

  • I can able to see the functions triggers Cosmos DB and create a database and collection in my account.

enter image description here

Output:

enter image description here

Check this SO link for reference.

Balaji
  • 311
  • 1
  • 3
0

It seems that my Azure Function is experiencing an issue with the Cosmos DB trigger using the MongoDB API. After reviewing the connection string and logs, I realized that the problem lies in the incompatibility between the Azure Cosmos DB trigger and Azure Cosmos DB with the MongoDB API.

The error occurs because the trigger I'm using was created from the "Azure Cosmos DB trigger" template, which is designed to work with Azure Cosmos DB for NoSQL. Unfortunately, it is not compatible with Azure Cosmos DB using the MongoDB API.

According to the official documentation, Azure Cosmos DB trigger bindings are only supported for Azure Cosmos DB for NoSQL, and they do not work with Azure Cosmos DB for MongoDB, Azure Cosmos DB for Cassandra, or Azure Cosmos DB for Apache Gremlin.

As a result, the trigger cannot start, and the error message "The listener for function 'Functions.CosmosTrigger1' was unable to start" appears.

Now I have a clear understanding of the issue. However, I believe I'll need to explore an alternative approach that allows me to stream data for this type of database. If anyone can suggest any ideas, I would greatly appreciate it.

Daniel Vera
  • 77
  • 1
  • 10