0
您好,我需要使用PowerShell與DocumentDB。我的代碼在這裏DocumentDB存儲過程錯誤
$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
有我們的收集,所有的好, 現在我們創建過程
$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.Result.Resource.Selflink我們有鏈接:DBS/ONIYAA ==/colls/ONIYAI9WJgA = /存儲過程/ ONIYAI9WJgAHAAAAAAAAgA ==/
現在我們可以嘗試執行程序,我們總是有誤差
$client.ExecuteStoredProcedureAsync($procedure.Result.Resource.Selflink)
錯誤日誌中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
爲什麼?
我不熟悉PowerShell中使用異步.NET包,所以我只有猜測,但會不會是你的CreateStoredProcedure電話還沒有結束並且當您調用ExecuteStoredProcedure時,您以$ procedure形式發送空值?你可以通過打印出$ procedure來確認這一點,儘管聽起來你可能已經這樣做了。 –