How to save and execute a stored procedure in cosmos db through azure portal?

Michael Rätzel picture Michael Rätzel · Aug 17, 2017 · Viewed 7.6k times · Source

I tried to do this from the Script Explorer->Stored Procedure view, but when I use the button Save & Execute there, it only gives results in the following error message:

Failed to save the script

Database Account: myaccountname, Script: HelloWorld, Message: {"code":500,"body":"{\"message\":\"An error has occurred.\"}"}

And the textbox under Results is unchanged.

Below is a screenshot of how it looks in azure portal: Azure portal does not Save and Execute Stored Procedure

Answer

Minh Duc Lai Trung picture Minh Duc Lai Trung · Sep 9, 2017

@MichaelRätzel: I have just written a very simple CosmosDB Script and run it on Azure Portal.

function TestSample() {
    getContext().getResponse().setBody("Hello World");
}

And here is my result:

Azure Portal screenshot of succesful save

I got the same problem with you about the Failed to save the stored procedure. What I did to solve that problem is:

  1. Save the Stored Procedure first
  2. Left-click to the current SP on the left column
  3. Save & Execute the SP

I think this is a technical issue of Azure Portal. Try this and tell me the result.