-
-
Save justinyoo/5990c22a51a958d6fd3d420952f5aea8 to your computer and use it in GitHub Desktop.
Azure Functions with IoC Container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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