Free enterprise applications using Azure Serverless

Rubicon Cloud Advisor
7 min readJan 30, 2020

We all love free stuff right? Why would you pay hundreds or even thousands a month, when you can have your application run for free?

Enterprise applications usually consist of a web interface, identity management, data and computation. What if I told you that you could have all those working together in one solution for free in Azure?

Do I have your attention? Good, because I tricked you a bit using the term ‘free’. I mean almost for free, but I can assure you that you can start creating complex solutions for less than one euro a month and most components will be free indeed.

Real world example

The solution I’m about to describe is a real world case. It has thousands of users, but for the sake of private knowledge I will describe it by means of an example company. This company wants to sell satellite images to layman customers. So a customer can register an account on their website, and request and receive images from a specific satellite for a small fee.

A customer requests images from a specific satellite

We need several components for this solution. A web interface for interacting with the customers. Identity management for registering and logging in users. Data for storing user history. A connection with an on-premise service that has all the satellite images and some computing to tie it all together.

Required solution components

Now we can have all these components, except for the existing on-premise service, for next to nothing using Azure. So, how do we do this? Let’s start with the data component.

NoNoSQL

Everybody knows SQL, right? But we don’t want to write Stored Procedures and write Update Scripts. We rather have our data structures evolve over time so we like to look at NoSQL options. Microsoft’s answer would be CosmosDB which actually would fit our approach. But both Azure SQL and CosmosDB are pretty expensive while there is a much cheaper alternative available.

Do you know NoNoSQL? No? Well, now you do. It’s Azure Table Storage, part of regular Storage Accounts. It provides a flexible way to store data and supports evolving data structures, like other NoSQL options. It lacks some advanced querying options, but it is more than enough for this use-case and most of all, it starts off for free. Sure, you will pay for storage usage and bandwidth usage, but compared to the alternatives this one starts with a few cents a month. As soon as heavy data usage kicks in, you will have to pay up, but this always stays within very reasonable amounts. Our real-world case used 6Gb of data bandwidth last month which only costs a mere 14 euros.

Using Azure Table Storage for Data Storage costs almost nothing.

Free Computing

Of course, the computing component is linking all the components and forcing the business rules. It’s the back-bone of the application and in traditional scenario’s a REST WebApi would be the de facto fit.

But looking at our requirements: stateless actions that support HTTP calls, Azure Functions would make a lot of sense. And why not have a Function for every back-end action? Like some kind of reduced version of a service, one might even call it micro, a micro service.

This is exactly the approach we took and it demonstrably works. And there is also another nice side effect for this way of designing the back-end. It forces the developer to think about the business domain and bounded contexts.

It gets interesting when we start to talk about the pricing. Azure Functions are by default on a Consumption Plan. This means that it scales the Functions from zero to infinite instances. With the Consumption Plan the price is 0,169 euros per million executes. 17 cents?! Per million actions?! And free scaling? And the icing on the cake is that the first million actions are free! We never hit that million actions, which means that all our computing is essentially for free.

Using Azure Functions as a back-end is totally free.

Using JavaScript pays off

“Any application that can be written in JavaScript, will eventually be written in JavaScript.“
— Jeff Atwood, StackOverflow Cofounder, 2007

I’ve had my fair share of JavaScript bashing. But when I stumbled on frameworks like KnockoutJS and AngularJS they really appealed to me. Now with React, Angular and Typescript there is no reason anymore to limit yourself to traditional ASP.NET or MVC.NET.

Another advantage of using Client-Side Frameworks is that it is only JavaScript, HTML and CSS. All static files, so very easy to host. Looking at Azure we have Azure Blob Storage that fits this purpose very neatly. Azure Blob Storage is part of regular Storage Accounts, just like Azure Table Storage. On Azure Blob Storage you can turn on the Static website option, and you will be able to deploy the static website files to a new container called $web.

With Azure Blob Storage it’s also possible to use custom domain names, which is a requirement as well. And if we want a SSL certificate, we have options for that, but we have to look further then Azure. SSL certificates within Azure are very expensive, but Cloudflare provides SSL for free.

Using Cloudflare SSL

Cloudflare is a CDN (Content Delivery Network) and has a free option that enables you to use SSL on your custom domain. On top of that you’ll enjoy the CDN capabilities which reduces the storage bandwidth massively.

In the end, the expenses for hosting the static website involves a tiny bit of storage and a tiny bit of bandwidth thanks to the CDN. The final result only costs a few cents.

Combining Cloudflare with Azure Blob Storage results in only a few cents of hosting expenses.

Sometimes there are better solutions outside Azure

With Cloudflare as an example, sometimes there are better solutions outside Azure. Even when there is an Azure option, it might be a good idea to look further then Microsoft alone. Azure AD B2C being a case in point. For our example we should use Azure AD B2C because looking at the specs it exactly fits our case and it’s free to use as well.

But Azure AD B2C is, in contrast with regular Azure AD, not very well documented and very hard to apply branding. There is also a free Identity Provider in the market called Auth0. Auth0 offers its services for free for the first 7000 users. It is very well supported and contains pre-built components for integrating with Angular.

Auth0 has a fantastic free offering that fit our Identity Management needs

Combining free options and good design

For retrieving the satellite images we have to connect to an on-premise service. Previously we would have opened a port on our on-premise firewall and have the service available publicly. But it’s also a bad design to rely on a synchronous local network connection.

Be prepared that on-premise connections will fail.

It is only a matter of ‘when’ the connection to your local network will fail. So a better option would be to use one of the messaging options that Azure provides. The most appealing solution for our need would be the Azure Service Bus Queue. It provides an asynchronous publisher-subscriber service.

Azure Service Bus Queue provides a pub-sub pattern.

Talking about pricing. It is five cents per million calls. In our real-world case we are never hitting one cent, so I would call this practically for free.

Azure Service Bus Queue is practically free and gives us asynchronous options to be prepared for failures

Final Score

Looking at the final picture we can conclude that we have a well-designed micro-service solution for next to nothing. It costs less than one euro a month!

Reaching outside Azure might be a bit unconventional, but it gives us great alternatives. Of course it’s perfectly possible to stay within Azure for SSL and Identity Management. But be prepared to pull out your wallet or undergo more difficult development.

You might call this approach progressive, but I hope at least that it gives an interesting perspective.

If you want to know more about this approach. Like the other concessions and considerations we took. Please contact me at j.paarhuis@rubicon.nl

--

--