Function vs. Web API.
I have several projects I have been looking at doing and I have been struggling with whether to use Azure functions or to build APIs and host them as an Azure app service.
In this post, I am going to try to figure out what is the best solution based on functionality, reuse, cost, maintenance, and ROI.
This post will not cover the in-depth technical difference between functions and web API. The end result is for me to understand which one will work under a different use case.
Advantages of Functions
a. Code in the Browser
Not only am I not interested in this one, I think it is a disadvantage. If you or your team are un-disciplined about your changes, a bad thing can happen.
b. Additional languages supported
Not interested in this one either. There is a side effect, what if a team member coded a function in Python and left the team, that supports it.
c. Point and click integration with other Azure services like Blob Storage and Comos
This is the only advantage that I think I would take advantage of. It is a nice feature to quickly add a new service and have access to it in your code.
d. Automatic Scaling
I see this as a double-edged sword. It is good when you are expecting a rise in usage or if you get a good review on something and it drastically increases traffic. On the other side, you could get surprised billing or unpredictable billing.
e. Pay Per Use
The free tier is nice, but you have to watch out for unexpected scaling
f. Logic application integration
I currently have no plans on building logic apps
g. Built for small automatic work
This is always a good starting point, but you can do this in your web API as well.
h. Has a timer endpoint
This is a nice feature, I can see using this type of function in conjunction with a Web API
Advantages of Web API
a. Code, debug, build, and deploy fits into your current workflow
To me, this is a very important advantage. I have a well-defined process and web API fits in nicely with it.
b. Handle bigger more complex methods
This should be avoided. You should be able to break down things into smaller parts, but it can't always be done that way.
c. Can access external resources, files, etc.
Many of my applications are dealing with files, text, images, etc.
d. Finer control of the API calls like setting your own routes
This could be a double-edged sword as well. I have seen developers over-engineer the routes just because they could.
e. Finer control over the scaling.
App services do have built-in features to help with scaling, but they are not as instant as with functions. But you can control the maximum amount to scale to. This will help on the billing side
The winner is?
Just like everything else in development, it depends, but for me, I will always start with Web API and evaluate the project to see if functions are a better option.
Comments
Post a Comment