public async Task <HttpResponseMessage> HandleRequestAsync(FunctionDescriptor function, HttpRequestMessage request, CancellationToken cancellationToken) { // All authentication is assumed to have been done on the request // BEFORE this method is called // Invoke the function ParameterDescriptor triggerParameter = function.Parameters.First(p => p.IsTrigger); Dictionary <string, object> arguments = new Dictionary <string, object> { { triggerParameter.Name, request } }; // Suspend the current synchronization context so we don't pass the ASP.NET // context down to the function. using (var syncContextSuspensionScope = new SuspendedSynchronizationContextScope()) { await Instance.CallAsync(function.Name, arguments, cancellationToken); } // Get the response HttpResponseMessage response = null; if (!request.Properties.TryGetValue <HttpResponseMessage>("MS_AzureFunctionsHttpResponse", out response)) { // the function was successful but did not write an explicit response response = new HttpResponseMessage(HttpStatusCode.OK); } return(response); }
public async Task<HttpResponseMessage> HandleRequestAsync(FunctionDescriptor function, HttpRequestMessage request, CancellationToken cancellationToken) { // All authentication is assumed to have been done on the request // BEFORE this method is called Dictionary<string, object> arguments = await GetFunctionArgumentsAsync(function, request); // Suspend the current synchronization context so we don't pass the ASP.NET // context down to the function. using (var syncContextSuspensionScope = new SuspendedSynchronizationContextScope()) { await Instance.CallAsync(function.Name, arguments, cancellationToken); } // Get the response HttpResponseMessage response = null; if (!request.Properties.TryGetValue<HttpResponseMessage>("MS_AzureFunctionsHttpResponse", out response)) { // the function was successful but did not write an explicit response response = new HttpResponseMessage(HttpStatusCode.OK); } return response; }