Instantly share code, notes, and snippets.

Embed
What would you like to do?
Is Azure Functions over Web API Beneficial?
// Azure Functions HTTP Trigger
// Endpoint URL: /api/products/{id}
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, int id, TraceWriter log)
{
// Handle HTTP Request Headers
// Handle HTTP Request Message
// Return HTTP Response
var msg = new { Id = id, Message = "Hello World" };
return req.CreateResponse(HttpStatusCode.OK, msg);
}
// ASP.NET Web API
// Endpoint URL: /products/{id}
[Route("products/{id}")]
[HttpGet]
public async Task<IActionResult> GetProduct(int id)
{
// Handle HTTP Request Headers
// Handle HTTP Request Message
// Return HTTP Response
var msg = new { Id = id, Message = "Hello World" };
return Ok(msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment