[英]DocumentDB stored procedure error
Hello i am need to use powershell with DocumentDB. 您好,我需要将Powershell与DocumentDB一起使用。 My code here 我的代码在这里
$url = "https://**********.documents.azure.com:443/"
$key = "*****************************"
$client = [Microsoft.Azure.Documents.Client.DocumentClient]::new([uri]$url,$key)
$db_list = $client.ReadDatabaseFeedAsync().Result
$coll_list = $client.ReadDocumentCollectionFeedAsync($db_list.CollectionsLink).Result
there we have collection, all good, now we create procedure 那里有收藏,一切都很好,现在我们创建程序
$proc = [Microsoft.Azure.Documents.StoredProcedure]::new()
$proc.id = 'hello_world'
$proc.body = 'function hello_world() {
var context = getContext();
var response = context.getResponse();
response.setBody("Hello, World");
}'
$procedure = $client.CreateStoredProcedureAsync($coll_list.SelfLink,$proc)
Procedure sucessfully created and in $procedure.Result.Resource.Selflink we have link : dbs/ONIYAA==/colls/ONIYAI9WJgA=/sprocs/ONIYAI9WJgAHAAAAAAAAgA==/ 成功创建了过程,并在$ procedure.Result.Resource.Selflink中建立了链接:dbs / ONIYAA == / colls / ONIYAI9WJgA = / sprocs / ONIYAI9WJgAHAAAAAAAAgA == /
now we can try to execute procedure and we always have error 现在我们可以尝试执行过程,并且总是有错误
$client.ExecuteStoredProcedureAsync($procedure.Result.Resource.Selflink)
Error log in ExecuteStoredProcedureAsync: ExecuteStoredProcedureAsync中的错误日志:
ErrorRecord : Unable to find an overload for "ExecuteStoredProcedureAsync" and a number of arguments: "2".
StackTrace : в CallSite.Target(Closure , CallSite , Object , Object , String
)
в System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet
](CallSite site, T0 arg0, T1 arg1, T2 arg2)
в System.Management.Automation.Interpreter.DynamicInstruction`4.
Run(InterpretedFrame frame)
в System.Management.Automation.Interpreter.EnterTryCatchFinallyI
nstruction.Run(InterpretedFrame frame)
WasThrownFromThrowStatement : False
Message : Unable to find an overload for "ExecuteStoredProcedureAsync" and a number of arguments: "2".
Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException :
TargetSite : System.Object CallSite.Target(System.Runtime.CompilerServices.Closu
re, System.Runtime.CompilerServices.CallSite, System.Object, System
.Object, System.String)
HelpLink :
Source : Anonymously Hosted DynamicMethods Assembly
HResult : -2146233087
Why? 为什么?
I suspect that you will need to pass in two parameters to $client.ExecuteStoredProcedureAsync()
. 我怀疑您需要将两个参数传递给$client.ExecuteStoredProcedureAsync()
。 The first parameter is a link to the stored procedure, and the second is an array of parameters to be pass in to the stored procedure itself. 第一个参数是到存储过程的链接,第二个是要传递到存储过程本身的参数数组。
Here is the corresponding C# code: 这是相应的C#代码:
await client.ExecuteStoredProcedureAsync<bool>("/dbs/db_rid/colls/col_rid/sprocs/sproc_rid/",
new Player { id="1", name="joe" } ,
new Player { id="2", name="john" }
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.