In AWS Lambda a serverless function is a small piece of code hosted somewhere. I can curl a url to run the code. In a python Function App v4, I seem to be forced to use a server. Is it possible to get a simple serverless function that just runs a piece of code like on AWS Lambda?
Removing the route annotations does not give a working function. Get a "no HTTP routes found" when I run the function locally.
2
Answers
Yes you can create simple serverless functions that run a piece of code in response to events, including HTTP triggers.
Here is a small example-Python Azure Function with an HTTP trigger:
Open a terminal in the function app folder and give this command – func start
For no HTTP –
doublee-check that the function is properly set with the @func.HttpTrigger
I don’t think an Azure Function Application uses a Flask server by default because this tutorial would not exist then. It is however definitely a server and you are forced to use it.
I do not get why it is the way it is, Microsoft is unique here. They call it a serverless function but in reality it is not. On AWS or GCP, if I want a second serverless function I would create another Lambda but on Azure have to edit the first function application and create another route. If I wanted routes and servers, I would just make one. It totally defeats the point of putting multiple small pieces of code in multiple functions and then exposing them through an API Gateway because there is one function application with all code running each time. In the end, we migrated out of Azure.