Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Azure Functions with IoC Container
public static class IndexHttpTrigger
{
public static IFunctionFactory FunctionFactory { get; set; } = new FunctionFactory();
[FunctionName("IndexHttpTrigger")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "pets")]HttpRequestMessage req,
TraceWriter log)
{
AglCodingTestHttpTriggerFunctionOptions options = GetOptions(req);
try
{
var res = await FunctionFactory.Create<IAglCodingTestHttpTriggerFunction>(log)
.InvokeAsync(req, options)
.ConfigureAwait(false);
return res as HttpResponseMessage;
}
catch (Exception ex)
{
return req.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment