I am trying to create a Stored Procedure and call it through .net core application.
This is how I created the SP -
var sysJs = azureDatabase.GetCollection(“System.js”);
var code = File.ReadAllText("…path\sum.js");
var codeDocument = new BsonDocument(“value”, new BsonJavaScript(code));
codeDocument.Add(new BsonElement("_id", “mathSum”));
sysJs.InsertOne(codeDocument);
2 Failed ways of calling it -
BsonValue bv = azureDatabase.Eval(“addNumbers(2,3)”);
where azureDatabase is Database reference object
var command = new JsonCommand($"{{ eval: “addNumbers({1},{2})” }}");
var result = azureDatabase.RunCommand(command)[“retval”].ToInt32();
which gives an exception that eval is not supported
Hi, welcome to MongoDB Community Forums, @Divya_Noor
Azure Cosmos DB is a Microsoft cloud database product with partial emulation for popular database APIs like MongoDB, Cassandra, and Gremlin. Cosmos’ MongoDB API provides an incomplete emulation of MongoDB using an entirely independent server implementation. MongoDB drivers and tools are not tested against CosmosDB, so if you encounter a compatibility error you should report this to Cosmos support.
Based on the error message you received, it’s not clear to me exactly what you are trying to do, and whether MongoDB or CosmosDB supports it. Are trying to run the (deprecated since 3.0) db.eval() command?
If full MongoDB feature support is important to your use case, please consider using MongoDB Atlas on Azure for a managed data service.
MongoDB Atlas is an excellent service that helps you run cloud-agnostic workloads in addition to offering latest MongoDB version since it’s all built by the same team.