Sources: Photo of flowing data by xresch from Pixabay, Azure logo by Microsoft, combined by the author.

Rapid prototyping — Azure Functions

An evaluation of Azure Functions from the prototyping perspective

Kristjan Eljand
6 min readAug 12, 2022

--

Introduction

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:

  1. Documentation & tutorials,
  2. Initial setup complexity,
  3. Development complexity,
  4. Deployment complexity,
  5. Authorization possibilities,
  6. Authorization complexity,
  7. Speed & scalability,
  8. Monitoring functionalities and ease of use,
  9. Pricing.

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.

A comprehensive development guide of Azure Functions (illustration by Author, snapshot from docs.microsoft.com)

Environment configuration

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.

VS Code with Azure extension is an easiest way to manage Azure Functions (illustration by Author).

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):

  1. Create your application code that you would like to make available to others.
  2. Create the local Azure function project through Azure function — Azure extension will automatically generate the boilerplate code for you.
  3. Wrap your application code inside Azure Functions boilerplate code.
  4. 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.

Example of wrapping your code inside Azure function by changing the `main` function inside `__init__.py` file (the file itself is generated automatically by Azure extension).

In general, the complexity of creating the first Azure function locally is Low-to-medium and takes not more than half an hour.

Deployment

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.

Example of deployed application that gives output in JSON format.

Authorization

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:

  1. anonymous — Everybody can access the function (no key is needed).
  2. function — A function-specific key is required.

The general structure of the anonymous function call:

https://<APP_NAME>.azurewebsites.net/api/<FUNCTION_NAME>`

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.

https://<APP_NAME>.azurewebsites.net/api/<FUNCTION_NAME>?code=<API_KEY>`

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:

  1. Consumption plan — fully serverless option where the function is scaled automatically based on the incoming events.
  2. Premium plan — scales automatically using pre-warmed workers (starts faster) and runs on more powerful instances (code runs faster).
  3. 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.

Snapshot of the performance metrics of a sample function. The performance has varied from less than a second to more than seven seconds.

Overall, the speed & scalability of Azure Functions is Very good for prototyping needs.

Monitoring

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.

Snapshot of the function execution count of the sample function. The monitoring options are available through Azure portal (image by author, snapshot from Azure portal).

Overall, monitoring your function is easy and covers the prototyping needs.

Pricing

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).

The actual cost of 3 Azure Functions that have been called few hundred times during the billing period shown on the image (image by Author, snapshot from Azure portal).

Summary

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:

  1. Documentation & tutorials — Very good
  2. Initial setup complexity — Medium
  3. Development complexity — Low-to-medium
  4. Deployment complexity — Low
  5. Authorization possibilities — High
  6. Authorization complexity — Low
  7. Speed & scalability — High level
  8. Monitoring — Highly functional out-of-box
  9. Pricing — Almost free (for prototyping)

Have fun prototyping!

--

--