20

I am working with Azure Cosmos DB, I am programming the client side in C# (web service) and I'm writing some server side Stored Procedures with java-script.

How can I debug my stored procedure's code?

Thanks,

MAK

CSharpRocks
  • 6,791
  • 1
  • 21
  • 27
MAK
  • 605
  • 9
  • 19

1 Answers1

25

Azure Cosmos DB stored procedure is JS script running on the server, you can not debug it on your side.

However , you can use console.log () to log some key steps in your stored procedure as below.

enter image description here

Then use getScriptLog to get the output from stored procedure console.log() statements.

Please note that EnableScriptLogging = true is necessary to print console.log:

var response = await client.ExecuteStoredProcedureAsync(
    document.SelfLink,
    new RequestOptions { EnableScriptLogging = true } );
Console.WriteLine(response.ScriptLog);

You could refer to this official doc.

Hope it helps you.

Jay Gong
  • 23,163
  • 2
  • 27
  • 32
  • your answer is good , it's give a good work around for that, but some problem , if we received unhandled exception the logger will not help us , another thing , we need to add the to the web setting – MAK Dec 20 '17 at 14:05
  • @MAK Yes, stored procedure js code runs at server side so that we can not debug it step by step. – Jay Gong Dec 21 '17 at 02:19
  • @JayGong is it possible to run the sproc from within the Azure portal and view the logs there? – David Klempfner Jul 11 '22 at 12:13