View profile

Why We Love Azure Functions for Node.js

Why We Love Azure Functions for Node.js
By Mastering JS Weekly • Issue #66 • View online

We’re now offering the opportunity to sponsor one of our weekly newsletters! Learn more on our new GitHub Sponsors page.
Check out our new GitHub Sponsors page!
Check out our new GitHub Sponsors page!
When we were looking to build our job board, we found ourselves with a conundrum. The job board was Mastering JS’ first backend code. Up until we launched our job board, our entire site was vanilla JavaScript we shipped to Netlify.
Maybe we were overthinking it, but we wanted to find a backend deployment paradigm we could honestly recommend to you, our readers. A deployment paradigm that helps you get from zero to HTTPS-enabled API with minimal headache. So far, Azure Functions has lived up to our expectations.
The most recent projects we’ve worked on involved DevOps alternatives that we didn’t like. Kubernetes is powerful, but way too heavy in terms of setup time and upkeep for a simple app. Shipping an Express app to an EC2 box is easy… until you want to support HTTPS. Then you find yourself in AWS hell.
AWS makes you feel like Sisyphus, always needing to add 1 more AWS service
AWS makes you feel like Sisyphus, always needing to add 1 more AWS service
We evaluated Azure Functions a few years ago as part of a general survey of the serverless landscape, and found it to be the best serverless platform for Node.js apps. When we re-evaluated in 2021, Azure Functions was even better. There’s no contest between Lambda and Azure Functions: Azure Functions is light years ahead.
One Command HTTPS Serverless Apps
What makes Azure Functions different? When you deploy an Azure Function App (an app is a collection of serverless functions, typically one GitHub repo) you immediately get a readable HTTPS-enabled URL for your Function App.
Deploy app, get URL. It's that easy.
Deploy app, get URL. It's that easy.
Seems simple and obvious, right? That’s exactly the point: if you manage to deploy a Function App, you immediately get a usable HTTPS endpoint.
Contrast this with AWS Lambda. AWS Lambda by itself is virtually useless because you can’t invoke your function via HTTP without correctly configuring Amazon API Gateway to talk to Lambda. Once you do that, you get an unreadable randomly-generated URL for invoking your Lambda function via HTTP.
AWS API Gateway URLs aren't very user friendly
AWS API Gateway URLs aren't very user friendly
If you want a human-readable URL for your Lambda function, you need to configure AWS Route 53 to talk to your API Gateway. And, if you want to support HTTPS, you need to configure AWS Certificate Manager correctly with both Route 53 and API Gateway.
In short, setting up AWS Lambda is about as efficient and delightful as a trip to the DMV. There are tools like Serverless that streamline Lambda setup, but, in our experience, AWS is completely unusable even with Serverless. With Azure Functions, you can skip dozens of hours of menial work and ship your apps with less headache.
Basic Monitoring Included
Azure Function Apps also come with some rudimentary monitoring that makes it easy to spot check your functions’ health. Azure gives each function invocation an id, and lists out recent invocations.
Click on an invocation, get logs
Click on an invocation, get logs
Azure’s monitoring could be better. But we like that you get some basic monitoring with zero additional setup: nothing’s more painful than trying to figure out why your app is broken in production without access to logs.
Plus, built-in monitoring and logging shows that Azure shares Mastering JS’ development philosophy: pragmatic solutions to real world problems (how do I ship my app?). No more getting lost in the minutiae of configuring resource policies and setting up IAM roles.
Ready to try Azure Functions? Here’s the tutorial we used to get started.
Most Recent Tutorials
How to Trim Leading Zeros from a String in JavaScript - Mastering JS
How to Deep Copy an Array in JavaScript - Mastering JS
What We're Reading
Making the Web. Faster.
Did you enjoy this issue?
Mastering JS Weekly

Pragmatic web development. No bloatware allowed!

In order to unsubscribe, click here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue