Serverless Azure Architecture, Simple Forms
I hate complex software, not just out of laziness (definitely a big part of it) but I honestly do think that simple software is easier to maintain in the long run and usually better asset to software companies than complex software is.
Azure has just recently gotten a new service “Azure Functions” : https://azure.microsoft.com/en-us/documentation/articles/functions-overview/ which is a fine example of simple thing that can drive enormous business value. Basically it is a system which allows You to create a reasonably rich solution by simple scripting while allowing serverless execution. This shifts the attention to application logic, not application infrastructure. Besides, scripting is fun … which is more important than one might think at first.
Scripting, not software development project
So I took a closer look at the functions and decided to test with something that has some real value, something that implements an actual use case that my customers have. This case is Simple Feedback Forms. Simple forms are basically forms that You might want to use when asking company’s employees whether they will participate to next field day and what employees thought of the services they’ve been getting from IT or customer feedback form … just to name a few usage scenarios.
I decided to implement the actual forms in HTML5 so users could use whatever clients they happen to have handy. The backend would be Azure Sql database for easy reporting. Finally the little logic (the script) in the middle would be implemented in C# even I have been writing a lot about Node.js and other non-microsoft languages, this time I just felt like writing some C#.
1. The browser makes a request towards our published function
2. The function fetches the correct form html from blobstorage and serves it to browser
3. The user fills in the form and presses submit
4. The function saves the data into Azure Sql Db for later processing
5. Power Bi report shows a report based on the collected data
Serverless doesn’t mean free
The cool thing is that we do not have to reserve any server capacity beforehand and we pay only for those seconds that our function does any processing. On top of this we have a cheap Sql Database and miniscule amount of storage on blob storage services. We can use the database for various other usages and same goes for the storage. I could have used a TableStorage for storing the data (cheaper than sql) but my customer is very good with sql reporting tools so let’s do it this time like this. One interesting result of my Sql usage was that the script needed more memory to run, instead of the minimal 128 MB the script required 256 , and that costs a tad more.
Implementation notes
The system was very easy to implement once I figured out the correct way to send and receive ajax-requests since there was not much documentation available at the time of writing. Another big thing was the pattern of utility modules, i.e. having all utility functions in a separate module so they would not clutter the main script logic. Overall a very enjoyable experience.
Resources
I have stored all the solution files and step-by-step guide here:
AppUtils.cs | |
App.cs | |
Step By step |
Whats next ?
Maybe user authentication for these forms and definitely some "Azure Functions"-based real time Dashboarding . Stay tuned ...