Azure Cosmos DB stored procedure is a JS script running on the server, you cannot debug it on your side.
However, you can use console.log () to register some key steps in your stored procedure, as shown below.

Then use getScriptLog to get the output from the console.log() stored procedures.
Note that EnableScriptLogging = true must print console.log:
var response = await client.ExecuteStoredProcedureAsync( document.SelfLink, new RequestOptions { EnableScriptLogging = true } ); Console.WriteLine(response.ScriptLog);
You can refer to the official document.
Hope this helps you.
source share