Rapid prototyping — Azure Functions
An evaluation of Azure Functions from the prototyping perspective
Azure Functions is a serverless solution which means that you don’t have to worry about the traditional server setup. It can be used for variety of scenarios including a) building a web API, b) running scheduled tasks, c) respond to events like database changes etc. This article gives you a general evaluation of the following topics from the perspective of prototyping needs:
- Documentation & tutorials,
- Initial setup complexity,
- Development complexity,
- Deployment complexity,
- Authorization possibilities,
- Authorization complexity,
- Speed & scalability,
- Monitoring functionalities and ease of use,
Documentation & tutorials
The usability of each product depends on how easy it is to understand it. The documentation of Azure Functions is comprehensive. You can start from the general overview or from a language specific quickstart and continue with the language specific developer guide or with some tutorial.
In addition, Github repos are available to be used as a boilerplate that you customize for your specific use-case.
Overall, Microsoft has made a very good job of documenting the Azure Functions.
The environment configuration includes 1.) Azure account creation (if you don’t have one) and 2.) installing necessary tools (Azure core tools, VS code and its extensions) (link to instructions for Python users). If you haven’t used Azure Functions before, then the most time-consuming part of publishing your first function.
I highly recommend using the VS Code with its extensions when developing your functions — it let’s you do everything from coding to deploying through an IDE.
In general, the complexity of environment setup is Medium when compared to other prototyping tools.
The process of creating the function
Creating your first Azure function is a four-step process (the step-by-step instruction for Python users):
- Create your application code that you would like to make available to others.
- Create the local Azure function project through Azure function — Azure extension will automatically generate the boilerplate code for you.
- Wrap your application code inside Azure Functions boilerplate code.
- Run & test the newly created Azure function locally.
Creating an Azure function means adding some code and configuration files to your environment that will wrap your existing code into a suitable format. Luckily, you don’t have to worry about creating this addition files yourself — Azure extension will create it automatically.
If you just want to publish your code as fast as possible then all you need to do is change the
__init__.py file inside the automatically generated function folder so that it includes the logic of your code. If you need to go deeper into all of the configuration possibilities then this instruction a good place to start.
In general, the complexity of creating the first Azure function locally is Low-to-medium and takes not more than half an hour.
You can use different approaches to deploy your Azure Functions to Azure cloud. For example, you can deploy directly from your development tool (as VS Code) or use an automated pipeline (e.g. Github Actions).
Deployment to the cloud involves two main steps: 1.) Creating the cloud resource and 2.) Deploying the application (step-by-step instructions for Python developers).
You don’t have to write any code — creating the resource means naming your cloud resources and selecting the server location. Deploying the application involves few clicks and everything else is handled automatically by the Azure extension.
In general, the complexity of deployment is Low when you are using the environment configuration described in the first section of this blog post.
Azure provides myriad of authentication methods to secure your serverless function. For prototyping, you probably want to go with one of the following authorization levels:
- anonymous — Everybody can access the function (no key is needed).
- function — A function-specific key is required.
The general structure of the anonymous function call:
A general structure of the request when your API is secured with a simple API key. You can generate and update the keys in Azure portal.
Overall, the possibilities for identity and access management are on High level and the complexity of implementing a simple authorization during the prototyping is Low.
Speed & scalability
Azure provides three main options for hosting and scaling:
- Consumption plan — fully serverless option where the function is scaled automatically based on the incoming events.
- Premium plan — scales automatically using pre-warmed workers (starts faster) and runs on more powerful instances (code runs faster).
- Dedicated plan — runs the functions within an App Service plan.
In most cases, you should only use the Consumption plan (default option) during prototyping (which enable you to pay only when the functions are running).
From my experience, you should expect the lag time of few seconds when you first call your function. Starting from the second call, the lag time goes down but varies from call to call.
Overall, the speed & scalability of Azure Functions is Very good for prototyping needs.
One of the most useful things of serverless products is the out-of-box monitoring and logging functionalities. For example, you can take a look at the usage statistics, drill into the performance of your function over time and monitor the logs in real-time.
Overall, monitoring your function is easy and covers the prototyping needs.
Azure Functions consumption plan is billed based on per-second resource consumption and executions. Consumption plan pricing includes a monthly free grant of 1 million requests and 400,000 GB-s of resource consumption per month per subscription in pay-as-you-go pricing across all function apps in that subscription.
Based on my experience, the cost of prototyping with Azure Functions is almost zero! The image below shows the total cost of 3 Azure Functions during the last 30 days (few hundred requests have been made to each function).
To summarize, I am highly impressed with the functionalities and the ease of use of Azure Functions. This is definitely a tool to consider when showing your prototypes to the world:
- Documentation & tutorials — Very good
- Initial setup complexity — Medium
- Development complexity — Low-to-medium
- Deployment complexity — Low
- Authorization possibilities — High
- Authorization complexity — Low
- Speed & scalability — High level
- Monitoring — Highly functional out-of-box
- Pricing — Almost free (for prototyping)
Have fun prototyping!