Skip to content

Instantly share code, notes, and snippets.

@christiannagel
Created July 2, 2018 21:14
Show Gist options
  • Save christiannagel/40fded4c5b2f5e4e86e9b49842674cd7 to your computer and use it in GitHub Desktop.
Save christiannagel/40fded4c5b2f5e4e86e9b49842674cd7 to your computer and use it in GitHub Desktop.
Azure Function returning a list of Book objects
public static class BooksFunction
{
[FunctionName("BooksFunction")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequest req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
return new OkObjectResult(GetBooks());
}
public static IEnumerable<Book> GetBooks()
=> new List<Book>
{
new Book(1, "Enterprise Services with the .NET Framework", "Addison Wesley"),
new Book(2, "Professional C# 6 and .NET Core 1.0", "Wrox Press"),
new Book(3, "Professional C# 7 and .NET Core 2.0", "Wrox Press")
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment