public Task<ServiceResponse<Invocation>> Put(InvocationRequest request) { return Client.PutAsync( "work/invocations", new ObjectContent<InvocationRequest>( request, JsonFormat.Formatter)) .AsServiceResponse<Invocation>(); }
public async Task SerializeToStreamAsync_SerializesNonModuleSourceTypeStreamInvocationRequestsAsync(ModuleSourceType dummyModuleSourceType) { // Arrange const string dummyModuleSource = "dummyModuleSource"; var dummyInvocationRequest = new InvocationRequest(dummyModuleSourceType, dummyModuleSource); var dummyJsonService = new JsonService(); using (ExposedInvocationContent testSubject = CreateInvocationContent(dummyJsonService, dummyInvocationRequest)) { var resultMemoryStream = new MemoryStream(); // Act await testSubject.ExposedSerializeToStreamAsync(resultMemoryStream, null).ConfigureAwait(false); // Assert resultMemoryStream.Position = 0; using (var resultReader = new StreamReader(resultMemoryStream)) { string result = resultReader.ReadToEnd(); Assert.Equal($"{{\"moduleSourceType\":{(int)dummyModuleSourceType},\"moduleSource\":\"{dummyModuleSource}\"}}", result); } } }
/// <summary> /// Invoke an orchestration function. /// </summary> private Hashtable InvokeOrchestrationFunction( PowerShellManager psManager, AzFunctionInfo functionInfo, InvocationRequest invocationRequest, FunctionInvocationPerformanceStopwatch stopwatch) { if (!Utils.AreDurableFunctionsEnabled()) { throw new NotImplementedException(PowerShellWorkerStrings.DurableFunctionNotSupported); } // Quote from https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-bindings: // // "Orchestrator functions should never use any input or output bindings other than the orchestration trigger binding. // Doing so has the potential to cause problems with the Durable Task extension because those bindings may not obey the single-threading and I/O rules." // // Therefore, it's by design that 'InputData' contains only one item, which is the metadata of the orchestration context. var context = invocationRequest.InputData[0]; var durableFuncContext = JsonConvert.DeserializeObject <OrchestrationContext>(context.Data.String); return(psManager.InvokeOrchestrationFunction(functionInfo, context.Name, durableFuncContext)); }
public void TestSetRetryContext_Retry() { ScriptInvocationContext context = new ScriptInvocationContext() { ExecutionContext = new ExecutionContext() { RetryContext = new Host.RetryContext() { RetryCount = 1, MaxRetryCount = 2, Exception = new Exception("test") } } }; InvocationRequest request = new InvocationRequest(); Grpc.ScriptInvocationContextExtensions.SetRetryContext(context, request); Assert.NotNull(request.RetryContext); Assert.Equal(request.RetryContext.RetryCount, 1); Assert.Equal(request.RetryContext.MaxRetryCount, 2); Assert.NotNull(request.RetryContext.Exception); }
public async Task TryInvokeAsync_ReturnsTupleContainingTrueAndAnObjectIfHttpResponseHas200StatusCodeAndTypeParameterIsAnObject() { // Arrange var dummyInvocationRequest = new InvocationRequest(ModuleSourceType.Cache, "dummyModuleSource"); Mock <HttpContent> mockRequestHttpContent = _mockRepository.Create <HttpContent>(); // HttpContent is an abstract class Mock <IHttpContentFactory> mockHttpContentFactory = _mockRepository.Create <IHttpContentFactory>(); mockHttpContentFactory.Setup(h => h.Create(dummyInvocationRequest)).Returns(mockRequestHttpContent.Object); var dummyHttpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StreamContent(new MemoryStream()) }; Mock <IHttpClientService> mockHttpClientService = _mockRepository.Create <IHttpClientService>(); mockHttpClientService.Setup(h => h.SendAsync(It.Is <HttpRequestMessage>(hr => ReferenceEquals(hr.Content, mockRequestHttpContent.Object)), HttpCompletionOption.ResponseHeadersRead, CancellationToken.None)). ReturnsAsync(dummyHttpResponseMessage); var dummyObject = new DummyClass(); Mock <IJsonService> mockJsonService = _mockRepository.Create <IJsonService>(); mockJsonService.Setup(j => j.DeserializeAsync <DummyClass>(It.IsAny <Stream>(), CancellationToken.None)).ReturnsAsync(dummyObject); #pragma warning disable IDE0067 ExposedHttpNodeJSService testSubject = CreateHttpNodeJSService(httpContentFactory: mockHttpContentFactory.Object, httpClientService: mockHttpClientService.Object, jsonService: mockJsonService.Object); #pragma warning disable IDE0067 // Act (bool success, DummyClass value) = await testSubject.ExposedTryInvokeAsync <DummyClass>(dummyInvocationRequest, CancellationToken.None).ConfigureAwait(false); // Assert _mockRepository.VerifyAll(); Assert.True(success); Assert.Same(dummyObject, value); }
/// <summary> /// Method to process a InvocationRequest. /// InvocationRequest should be processed in parallel eventually. /// </summary> internal StreamingMessage ProcessInvocationRequest(StreamingMessage request) { InvocationRequest invocationRequest = request.InvocationRequest; StreamingMessage response = NewStreamingMessageTemplate( request.RequestId, StreamingMessage.ContentOneofCase.InvocationResponse, out StatusResult status); response.InvocationResponse.InvocationId = invocationRequest.InvocationId; // Invoke powershell logic and return hashtable of out binding data try { // Load information about the function var functionInfo = _functionLoader.GetFunctionInfo(invocationRequest.FunctionId); _powerShellManager.RegisterFunctionMetadata(functionInfo); Hashtable results = functionInfo.Type == AzFunctionType.OrchestrationFunction ? InvokeOrchestrationFunction(functionInfo, invocationRequest) : InvokeSingleActivityFunction(functionInfo, invocationRequest); BindOutputFromResult(response.InvocationResponse, functionInfo, results); } catch (Exception e) { status.Status = StatusResult.Types.Status.Failure; status.Exception = e.ToRpcException(); } finally { _powerShellManager.UnregisterFunctionMetadata(); } return(response); }
public void Invoke(ScriptInvocationContext context) { if (context.CancellationToken.IsCancellationRequested) { context.ResultSource.SetCanceled(); return; } var functionMetadata = context.FunctionMetadata; InvocationRequest invocationRequest = new InvocationRequest() { FunctionId = functionMetadata.FunctionId, InvocationId = context.ExecutionContext.InvocationId.ToString(), }; foreach (var pair in context.BindingData) { invocationRequest.TriggerMetadata.Add(pair.Key, pair.Value.ToRpc()); } foreach (var input in context.Inputs) { invocationRequest.InputData.Add(new ParameterBinding() { Name = input.name, Data = input.val.ToRpc() }); } _executingInvocations.TryAdd(invocationRequest.InvocationId, context); Send(new StreamingMessage { InvocationRequest = invocationRequest }); }
public Task <InvocationResponse> Invoke(string skillId, InvocationRequest request) { return(Inner.Invoke(skillId, request)); }
/// <summary> /// Invoke a regular function or an activity function. /// </summary> private Hashtable InvokeSingleActivityFunction(PowerShellManager psManager, AzFunctionInfo functionInfo, InvocationRequest invocationRequest) { const string InvocationId = "InvocationId"; const string FunctionDirectory = "FunctionDirectory"; const string FunctionName = "FunctionName"; // Bundle all TriggerMetadata into Hashtable to send down to PowerShell Hashtable triggerMetadata = null; if (functionInfo.HasTriggerMetadataParam) { triggerMetadata = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (var dataItem in invocationRequest.TriggerMetadata) { // MapField<K, V> is case-sensitive, but powershell is case-insensitive, // so for keys differ only in casing, the first wins. if (!triggerMetadata.ContainsKey(dataItem.Key)) { triggerMetadata.Add(dataItem.Key, dataItem.Value.ToObject()); } } if (!triggerMetadata.ContainsKey(InvocationId)) { triggerMetadata.Add(InvocationId, invocationRequest.InvocationId); } if (!triggerMetadata.ContainsKey(FunctionDirectory)) { triggerMetadata.Add(FunctionDirectory, functionInfo.FuncDirectory); } if (!triggerMetadata.ContainsKey(FunctionName)) { triggerMetadata.Add(FunctionName, functionInfo.FuncName); } } return(psManager.InvokeFunction(functionInfo, triggerMetadata, invocationRequest.InputData)); }
private static Task <InvocationResponse> GetPidDllImportAsync(InvocationRequest invocation) { var isSuccess = getpid() > 0; return(Task.FromResult(GetInvocationResponse(nameof(GetPidDllImportAsync), isSuccess))); }
private static async Task <InvocationResponse> AggregateExceptionNotUnwrappedAsync(InvocationRequest invocation) { // do something async so this function is compiled as async var dummy = await Task.FromResult("xyz"); throw new AggregateException("AggregateException thrown from an async handler."); }
private static Task <InvocationResponse> NetworkingProtocolsAsync(InvocationRequest invocation) { var type = typeof(Socket).GetTypeInfo().Assembly.GetType("System.Net.SocketProtocolSupportPal"); var method = type.GetMethod("IsProtocolSupported", BindingFlags.NonPublic | BindingFlags.Static); var ipv4Supported = method.Invoke(null, new object[] { AddressFamily.InterNetwork }); var ipv6Supported = method.Invoke(null, new object[] { AddressFamily.InterNetworkV6 }); Exception ipv4SocketCreateException = null; try { using (Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { } } catch (Exception e) { ipv4SocketCreateException = e; } Exception ipv6SocketCreateException = null; try { using (Socket s = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp)) { } } catch (Exception e) { ipv6SocketCreateException = e; } string returnValue = ""; if (!(bool)ipv4Supported) { returnValue += "For System.Net.SocketProtocolSupportPal.IsProtocolSupported(AddressFamily.InterNetwork) Expected true, Actual false" + Environment.NewLine; } if ((bool)ipv6Supported) { returnValue += "For System.Net.SocketProtocolSupportPal.IsProtocolSupported(AddressFamily.InterNetworkV6) Expected false, Actual true" + Environment.NewLine; } if (ipv4SocketCreateException != null) { returnValue += "Error creating IPV4 Socket: " + ipv4SocketCreateException + Environment.NewLine; } if (ipv6SocketCreateException == null) { returnValue += "When creating IPV6 Socket expected exception, got none." + Environment.NewLine; } if (ipv6SocketCreateException != null && ipv6SocketCreateException.Message != "Address family not supported by protocol") { returnValue += "When creating IPV6 Socket expected exception 'Address family not supported by protocol', actual '" + ipv6SocketCreateException.Message + "'" + Environment.NewLine; } if (String.IsNullOrEmpty(returnValue)) { returnValue = "SUCCESS"; } return(Task.FromResult(GetInvocationResponse(nameof(NetworkingProtocolsAsync), returnValue))); }
private static async Task HandleInvocationRequest(InvocationRequest invokeRequest) { var status = new StatusResult() { Status = StatusResult.Types.Status.Success }; var response = new StreamingMessage() { RequestId = s_requestId, InvocationResponse = new InvocationResponse() { InvocationId = invokeRequest.InvocationId, Result = status } }; var metadata = s_loadedFunctions[invokeRequest.FunctionId]; // Not exactly sure what to do with bindings yet, so only handles 'httpTrigger-in' + 'http-out' string outHttpName = null; foreach (var binding in metadata.Bindings) { if (binding.Value.Direction == BindingInfo.Types.Direction.In) { continue; } if (binding.Value.Type == "http") { outHttpName = binding.Key; break; } } if (outHttpName == null) { status.Status = StatusResult.Types.Status.Failure; status.Result = "PowerShell worker only handles http out binding for now."; } else { object argument = null; foreach (var input in invokeRequest.InputData) { if (input.Data != null && input.Data.Http != null) { argument = input.Data.Http.Query.GetValueOrDefault("name", "Azure Functions"); } } s_ps.AddCommand(metadata.ScriptFile); if (argument != null) { s_ps.AddArgument(argument); } TypedData retValue; try { var results = s_ps.Invoke <string>(); retValue = new TypedData() { String = String.Join(',', results) }; } finally { s_ps.Commands.Clear(); } // This is just mimic what nodejs worker does var paramBinding = new ParameterBinding() { Name = outHttpName, Data = new TypedData() { Http = new RpcHttp() { StatusCode = "200", Body = retValue } } }; // Not exactly sure which one to use for what scenario, so just set both. response.InvocationResponse.OutputData.Add(paramBinding); response.InvocationResponse.ReturnValue = retValue; } await s_call.RequestStream.WriteAsync(response); }
public IResult <InvocationResponse> InvokeOperation(string operationId, InvocationRequest invocationRequest) { return(submodelClient.InvokeOperation(operationId, invocationRequest)); }
internal StreamingMessage ProcessInvocationRequest(StreamingMessage request) { InvocationRequest invocationRequest = request.InvocationRequest; // Assume success unless something bad happens var status = new StatusResult() { Status = StatusResult.Types.Status.Success }; var response = new StreamingMessage() { RequestId = request.RequestId, InvocationResponse = new InvocationResponse() { InvocationId = invocationRequest.InvocationId, Result = status } }; // Invoke powershell logic and return hashtable of out binding data try { // Load information about the function var functionInfo = _functionLoader.GetFunctionInfo(invocationRequest.FunctionId); // Bundle all TriggerMetadata into Hashtable to send down to PowerShell var triggerMetadata = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (var dataItem in invocationRequest.TriggerMetadata) { // MapField<K, V> is case-sensitive, but powershell is case-insensitive, // so for keys differ only in casing, the first wins. if (!triggerMetadata.ContainsKey(dataItem.Key)) { triggerMetadata.Add(dataItem.Key, dataItem.Value.ToObject()); } } // Set the RequestId and InvocationId for logging purposes Hashtable result = null; result = _powerShellManager.InvokeFunction( functionInfo.ScriptPath, functionInfo.EntryPoint, triggerMetadata, invocationRequest.InputData); // Set out binding data and return response to be sent back to host foreach (KeyValuePair <string, BindingInfo> binding in functionInfo.OutputBindings) { // if one of the bindings is '$return' we need to set the ReturnValue if (string.Equals(binding.Key, "$return", StringComparison.OrdinalIgnoreCase)) { response.InvocationResponse.ReturnValue = result[binding.Key].ToTypedData(); continue; } ParameterBinding paramBinding = new ParameterBinding() { Name = binding.Key, Data = result[binding.Key].ToTypedData() }; response.InvocationResponse.OutputData.Add(paramBinding); } } catch (Exception e) { status.Status = StatusResult.Types.Status.Failure; status.Exception = e.ToRpcException(); } return(response); }
public IResult <CallbackResponse> InvokeOperationAsync(string operationId, InvocationRequest invocationRequest) { if (Submodel == null) { return(new Result <CallbackResponse>(false, new NotFoundMessage("Submodel"))); } if (invocationRequest == null) { return(new Result <CallbackResponse>(new ArgumentNullException(nameof(invocationRequest)))); } var operation_Retrieved = RetrieveOperation(operationId); if (operation_Retrieved.Success && operation_Retrieved.Entity != null) { Delegate methodDelegate; if (operation_Retrieved.Entity.OnMethodCalled != null) { methodDelegate = operation_Retrieved.Entity.OnMethodCalled; } else if (methodCalledHandler.TryGetValue(operationId, out Delegate handler)) { methodDelegate = handler; } else { return(new Result <CallbackResponse>(false, new NotFoundMessage($"MethodHandler for {operationId}"))); } var invocationTask = Task.Run(() => { InvocationResponse invocationResponse = new InvocationResponse(invocationRequest.RequestId); SetInvocationResult(operationId, invocationRequest.RequestId, ref invocationResponse); try { invocationResponse.ExecutionState = ExecutionState.Running; Task <OperationResult> taskResult = (Task <OperationResult>)methodDelegate.DynamicInvoke(operation_Retrieved.Entity, invocationRequest.InputArguments, invocationResponse.OutputArguments); invocationResponse.OperationResult = taskResult.Result; invocationResponse.ExecutionState = ExecutionState.Completed; } catch (Exception e) { invocationResponse.ExecutionState = ExecutionState.Failed; invocationResponse.OperationResult = new OperationResult(e); } }); string endpoint = ServiceDescriptor?.Endpoints?.FirstOrDefault()?.Address; CallbackResponse callbackResponse = new CallbackResponse(invocationRequest.RequestId); if (string.IsNullOrEmpty(endpoint)) { callbackResponse.CallbackUrl = new Uri($"/operations/{operationId}/invocationList/{invocationRequest.RequestId}", UriKind.Relative); } else { callbackResponse.CallbackUrl = new Uri($"{endpoint}/operations/{operationId}/invocationList/{invocationRequest.RequestId}", UriKind.Absolute); } return(new Result <CallbackResponse>(true, callbackResponse)); } return(new Result <CallbackResponse>(operation_Retrieved)); }
public static async Task <InvocationRequest> ToRpcInvocationRequest(this ScriptInvocationContext context, ILogger logger, GrpcCapabilities capabilities, bool isSharedMemoryDataTransferEnabled, ISharedMemoryManager sharedMemoryManager) { bool excludeHttpTriggerMetadata = !string.IsNullOrEmpty(capabilities.GetCapabilityState(RpcWorkerConstants.RpcHttpTriggerMetadataRemoved)); var invocationRequest = new InvocationRequest { FunctionId = context.FunctionMetadata.GetFunctionId(), InvocationId = context.ExecutionContext.InvocationId.ToString(), TraceContext = GetRpcTraceContext(context.Traceparent, context.Tracestate, context.Attributes, logger), }; SetRetryContext(context, invocationRequest); var rpcValueCache = new Dictionary <object, TypedData>(); Dictionary <object, RpcSharedMemory> sharedMemValueCache = null; StringBuilder logBuilder = null; bool usedSharedMemory = false; if (isSharedMemoryDataTransferEnabled) { sharedMemValueCache = new Dictionary <object, RpcSharedMemory>(); logBuilder = new StringBuilder(); } foreach (var input in context.Inputs) { RpcSharedMemory sharedMemValue = null; ParameterBinding parameterBinding = null; if (isSharedMemoryDataTransferEnabled) { // Try to transfer this data over shared memory instead of RPC if (input.val == null || !sharedMemValueCache.TryGetValue(input.val, out sharedMemValue)) { sharedMemValue = await input.val.ToRpcSharedMemoryAsync(logger, invocationRequest.InvocationId, sharedMemoryManager); if (input.val != null) { sharedMemValueCache.Add(input.val, sharedMemValue); } } } if (sharedMemValue != null) { // Data was successfully transferred over shared memory; create a ParameterBinding accordingly parameterBinding = new ParameterBinding { Name = input.name, RpcSharedMemory = sharedMemValue }; usedSharedMemory = true; logBuilder.AppendFormat("{0}:{1},", input.name, sharedMemValue.Count); } else { // Data was not transferred over shared memory (either disabled, type not supported or some error); resort to RPC TypedData rpcValue = null; if (input.val == null || !rpcValueCache.TryGetValue(input.val, out rpcValue)) { rpcValue = await input.val.ToRpc(logger, capabilities); if (input.val != null) { rpcValueCache.Add(input.val, rpcValue); } } parameterBinding = new ParameterBinding { Name = input.name, Data = rpcValue }; } invocationRequest.InputData.Add(parameterBinding); } foreach (var pair in context.BindingData) { if (ShouldSkipBindingData(pair, context, excludeHttpTriggerMetadata)) { continue; } if (!rpcValueCache.TryGetValue(pair.Value, out TypedData rpcValue)) { rpcValue = await pair.Value.ToRpc(logger, capabilities); rpcValueCache.Add(pair.Value, rpcValue); } invocationRequest.TriggerMetadata.Add(pair.Key, rpcValue); } if (usedSharedMemory) { logger.LogDebug("Shared memory usage for request of invocation Id: {Id} is {SharedMemoryUsage}", invocationRequest.InvocationId, logBuilder.ToString()); } return(invocationRequest); }
public IResult <CallbackResponse> InvokeOperationAsync(string operationId, InvocationRequest invocationRequest) { return(submodelServiceProvider.InvokeOperationAsync(operationId, invocationRequest)); }
internal static async Task <InvocationResponse> InvocationRequestHandlerAsync(InvocationRequest request, IFunctionsApplication application, IInvocationFeaturesFactory invocationFeaturesFactory, ObjectSerializer serializer, IOutputBindingsInfoProvider outputBindingsInfoProvider) { FunctionContext? context = null; FunctionInvocation?invocation = null; InvocationResponse response = new() { InvocationId = request.InvocationId }; try { invocation = new GrpcFunctionInvocation(request); IInvocationFeatures invocationFeatures = invocationFeaturesFactory.Create(); invocationFeatures.Set <FunctionInvocation>(invocation); context = application.CreateContext(invocationFeatures); invocationFeatures.Set <IFunctionBindingsFeature>(new GrpcFunctionBindingsFeature(context, request, outputBindingsInfoProvider)); await application.InvokeFunctionAsync(context); var functionBindings = context.GetBindings(); foreach (var binding in functionBindings.OutputBindingData) { var parameterBinding = new ParameterBinding { Name = binding.Key }; if (binding.Value is not null) { parameterBinding.Data = await binding.Value.ToRpcAsync(serializer); } response.OutputData.Add(parameterBinding); } if (functionBindings.InvocationResult != null) { TypedData?returnVal = await functionBindings.InvocationResult.ToRpcAsync(serializer); response.ReturnValue = returnVal; } response.Result = new StatusResult { Status = StatusResult.Types.Status.Success }; } catch (Exception ex) { response.Result = new StatusResult { Exception = ex.ToRpcException(), Status = StatusResult.Types.Status.Failure }; } finally { (context as IDisposable)?.Dispose(); } return(response); }
/// <summary> /// Invoke a regular function or an activity function. /// </summary> private Hashtable InvokeSingleActivityFunction(PowerShellManager psManager, AzFunctionInfo functionInfo, InvocationRequest invocationRequest) { // Bundle all TriggerMetadata into Hashtable to send down to PowerShell var triggerMetadata = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (var dataItem in invocationRequest.TriggerMetadata) { // MapField<K, V> is case-sensitive, but powershell is case-insensitive, // so for keys differ only in casing, the first wins. if (!triggerMetadata.ContainsKey(dataItem.Key)) { triggerMetadata.Add(dataItem.Key, dataItem.Value.ToObject()); } } return(psManager.InvokeFunction(functionInfo, triggerMetadata, invocationRequest.InputData)); }
private static Task <InvocationResponse> ToUpperAsync(InvocationRequest invocation) { var input = JsonSerializer.Deserialize <string>(invocation.InputStream); return(Task.FromResult(GetInvocationResponse(nameof(ToUpperAsync), input.ToUpper()))); }
/// <summary> /// Invoke an orchestration function. /// </summary> private Hashtable InvokeOrchestrationFunction(AzFunctionInfo functionInfo, InvocationRequest invocationRequest) { throw new NotImplementedException("Durable function is not yet supported for PowerShell"); }
private static Task <InvocationResponse> HandlerEnvVarAsync(InvocationRequest invocation) { return(Task.FromResult(GetInvocationResponse(nameof(HandlerEnvVarAsync), LambdaEnvironment.Handler))); }
protected override async Task OnExecute(SubscriptionCloudCredentials credentials) { if (!String.IsNullOrEmpty(EncodedPayload)) { Payload = Encoding.UTF8.GetString(Convert.FromBase64String(EncodedPayload)); } if (ServiceUri == null) { await Console.WriteErrorLine(Strings.ParameterRequired, "SerivceUri"); } else { Dictionary<string, string> payload = null; if(!String.IsNullOrEmpty(Payload)) { payload = InvocationPayloadSerializer.Deserialize(Payload); } var bodyValue = new InvocationRequest( Job, "Scheduler", payload) { JobInstanceName = InstanceName, UnlessAlreadyRunning = Singleton }; var body = JsonFormat.Serialize(bodyValue); var request = new JobCreateOrUpdateParameters() { StartTime = StartTime, Action = new JobAction() { Type = JobActionType.Https, Request = new JobHttpRequest() { Uri = new Uri(ServiceUri, "work/invocations"), Method = "PUT", Body = body, Headers = new Dictionary<string, string>() { { "Content-Type", "application/json" }, { "Authorization", GenerateAuthHeader(Password) } } } // TODO: Retry Policy }, Recurrence = new JobRecurrence() { Count = Count, EndTime = EndTime, Frequency = Frequency, Interval = Interval // TODO: Schedule field? } }; using (var client = CloudContext.Clients.CreateSchedulerClient(credentials, CloudService, Collection)) { await Console.WriteInfoLine(Strings.Scheduler_NewJobCommand_CreatingJob, Job, CloudService, Collection); if (WhatIf) { await Console.WriteInfoLine(Strings.Scheduler_NewJobCommand_WouldCreateJob, JsonConvert.SerializeObject(request, new JsonSerializerSettings() { Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() })); } else { var response = await client.Jobs.CreateOrUpdateAsync(InstanceName, request, CancellationToken.None); await Console.WriteObject(response.Job); } await Console.WriteInfoLine(Strings.Scheduler_NewJobCommand_CreatedJob, Job, CloudService, Collection); } } }
private static Task <InvocationResponse> TooLargeResponseBodyAsync(InvocationRequest invocation) { return(Task.FromResult(GetInvocationResponse(nameof(TooLargeResponseBodyAsync), SevenMBString.Value))); }
private ExposedInvocationContent CreateInvocationContent(IJsonService jsonService = null, InvocationRequest invocationRequest = null) { return(new ExposedInvocationContent(jsonService, invocationRequest)); }
private static Task <InvocationResponse> GetTimezoneNameAsync(InvocationRequest invocation) { return(Task.FromResult(GetInvocationResponse(nameof(GetTimezoneNameAsync), TimeZoneInfo.Local.Id))); }
public ExposedInvocationContent(IJsonService jsonService, InvocationRequest invocationRequest) : base(jsonService, invocationRequest) { }
/// <summary> /// Invoke an orchestration function. /// </summary> private Hashtable InvokeOrchestrationFunction(PowerShellManager psManager, AzFunctionInfo functionInfo, InvocationRequest invocationRequest) { throw new NotImplementedException(PowerShellWorkerStrings.DurableFunctionNotSupported); }
public GrpcFunctionBindingsFeature(FunctionContext context, InvocationRequest invocationRequest, IOutputBindingsInfoProvider outputBindingsInfoProvider) { _context = context ?? throw new ArgumentNullException(nameof(context)); _invocationRequest = invocationRequest ?? throw new ArgumentNullException(nameof(invocationRequest)); _outputBindingsInfoProvider = outputBindingsInfoProvider ?? throw new ArgumentNullException(nameof(outputBindingsInfoProvider)); }
public async Task <IResult <InvocationResponse> > InvokeOperationAsync(string operationId, InvocationRequest invocationRequest) { var request = base.CreateJsonContentRequest(GetUri(OPERATIONS, operationId), HttpMethod.Post, invocationRequest); var response = await SendRequestAsync(request); return(await EvaluateResponseAsync <InvocationResponse>(response, response.Entity)); }
public GrpcFunctionInvocation(InvocationRequest invocationRequest) { _invocationRequest = invocationRequest; TraceContext = new DefaultTraceContext(_invocationRequest.TraceContext.TraceParent, _invocationRequest.TraceContext.TraceState); }