My Isolated Azure functions cosmosDB trigger is invoked saying there are new changes on the container. But no new changes are received and the execution fails. This is creating false alerts as the request fails. Below are the two messages in the logs. How to fix this ?
Executing 'Functions.TestCosmosDBTrigger' (Reason='New changes on container TestContainer at 2023-02-16T00:09:39.3365522Z', Id=xxxxx-xxxx-xxx)
Executed 'Functions.TestCosmosDBTrigger' (Failed, Id=xxxxx-xxxx-xxx, Duration=86ms)
Edit:
[Function("TestCosmosDBTrigger")]
public async Task RunAsync([CosmosDBTrigger(
databaseName: "testdata",
containerName: "TestContainer",
Connection = "connect",
LeaseContainerName = "leases")] IReadOnlyList<MyDocument> input)
{
//first line
logger.LogInformation("Received count {}", input.Count);
}
Update :
After enabling logs. The only relevant logs available are as below:
"Category":"Host.Triggers.CosmosDB","LogLevel":"Error","prop__{OriginalFormat}":"Lease {LeaseToken} experienced an error during processing


Most commonly you are experiencing processing/unhandled exceptions in your Function code.
The CosmosDBTrigger has detailed logs that can tell you what the problem is and help in debugging multiple scenarios.
Edit the
host.jsonfile in your project and add the logging configuration for the Trigger as per https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-configure-cosmos-db-trigger#enabling-trigger-specific-logs. You can select the log level you desire (if you are debugging I would recommendDebugtemporarily until you figure out the problem, then you can leave it asError).Example
host.json:Your file might already have other content, make sure you add it to the
loggingsection.EDIT AFTER NEW CODE: The most common cause is a deserialization error, it will show up in the Trigger logs. The SDK is trying to take the raw JSON and deserialize it to
MyDocumentand might be failing due to something on that class definition. Enable the logs for more information.EDIT AFTER LOGS: The logs show that the changes are delivered to your Function code, and there is a processing error. This error can be either an unhandled exception during execution or a serialization error. Check for the "Exception" column on App Insight logs. Based on comments, if you want to use System.Text.Json, you need to customize the serialization engine: https://stackoverflow.com/a/71243311/5641598