Hello @Mohammadfaizan Shaikh ,
welcome to this moderated Azure community forum.
You are using 'serverless' compute which that is stateless.
This means that every time the function is triggered, all logic in the function must be created again, including database connections.
Depending on how you program, the sample you have used, and the programming language, it's recommended to start with adding more debug lines.
This gives you more information about what is happening.
Also, add more exception handling, especially around DB commands.
If you are using C#, you can consider putting the connection instance in a static member. This way is survives the stateless behavior. Be aware you must be able to renew the connection if needed.
Lastly, check out the CosmosDB output binding.
The Azure Cosmos DB output binding lets you write a new document to an Azure Cosmos DB database using the SQL API.
Can this work for you?
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.