-
-
Save justinyoo/004994979f219d1c79b1c65ae90d91f5 to your computer and use it in GitHub Desktop.
Is Azure Functions over Web API Beneficial?
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
// 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