Здравствуйте, мне нужно использовать 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 у нас есть ссылка: д.б.н./ONIYAA ==/colls/ONIYAI9WJgA =/sprocs/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 в строке, хотя похоже, что вы уже это сделали. –