2

I'm following some Azure Function tutorials on creating a REST API, this all seems straight forward. However I'm struggling to understand how I should deal with the different verbs.

Is the recommended practice to create a separate Azure Function for each verb? And then also separate functions for each variation of routing for each verb, so a e.g. a separete function for each of:

  1. products/{productid} (GET)
  2. products (GET, returns list)
  3. products/me (GET returns a list of products belonging to the user making the request)

It seems to me I'm going to end up with a lot of Azure functions here. In the WebAPI approach I would have put all these in a single controller and the attribute routing would have taken care of the rest.

Is there another way to achieve this with Azure function?

2
  • Possible duplicate of AzureFunctions as a WebApp guidance Commented Apr 13, 2017 at 12:29
  • In fact that link seems to detail using proxies to map multiple user URL requests to one API endpoint. In my scenario I want to know if I should be using a single Azure Function to manage multiple verbs (Get, Put...) requests, or creating multiple Azure Functions Commented Apr 13, 2017 at 12:37

1 Answer 1

3

You can use Azure Function Proxies to setup routing for HTTP verbs and parameters and then pass the call down to a single function. Creating a function per each verb/parameter combination seems to be an overkill.

Of course, if processing logic is completely different e.g. for GET vs POST, it makes sense to put those into separate functions. So, in the end it's your call, but you have tools for both scenarios.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.