I'm still trying to learn about Azure Functions and best practices, but as I understand there are two ways to separate logic by http verb (GET, POST, etc.). Is there a standard or best practice that would prefer either of the two below methods? And more importantly, is there a cost difference between the two methods when running in Azure, assuming the underlying logic stays the same?
Method A:
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req)
{
if (req.Method == HttpMethods.Get)
{
// do stuff here
}
else if (req.Method == HttpMethods.Post)
{
// do stuff here
}
}
}
Method B:
public static class GetFunction
{
[FunctionName("GetFunction")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req)
{
// do stuff here
}
}
public static class PostFunction
{
[FunctionName("PostFunction")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req)
{
// do stuff here
}
}