Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created November 15, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/5990c22a51a958d6fd3d420952f5aea8 to your computer and use it in GitHub Desktop.
Save justinyoo/5990c22a51a958d6fd3d420952f5aea8 to your computer and use it in GitHub Desktop.
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