DEV Community

loading...

Going Serverless Azure

jordanfinners profile image Jordan Finneran Originally published at jordanfinners.dev Updated on ・5 min read

Continuing from my previous post.

I want to focus on a few serverless providers, this time Azure.

As a major cloud provider Azure offer all the serverless services you would expect:

  • Blob Storage for serving images and now websites too!
  • Functions for creating web services/API’s
  • Cosmos DB for Database As A Service
  • Azure B2C/B2B/Active Directory for Authentication

And loads more…


I’m going to focus on a few key services that I use and really like.

Azure Cosmos DB

This is Azure’s premier database as a service offering, it offers multiple different API’s to interact with it including MongoDB, Cassandra, Gremlin and SQL Core API. If you want NoSQL data but to be able to query it with SQL like API then Cosmos also offers this, and because it supports many different API’s migrating to Cosmos is really straight forward.

The JavaScript SDK for it is great, and handles lots of things that can usually be a pain including back offs and pagination. The storage is unlimited and you only pay for the throughput so it scales really well, especially using the SDK as if you get more requests than your throughput it’ll back off and handle the load.

Downside — Price

Let me skip right to the point, the only real downside I’ve found is cost, it is not cheap, but depends on your usage and having to take into account not managing anything.


Azure Storage

This is the blob storage offering from Azure, and now offers serving a website straight from storage! This is great for single page applications and means you will never have scaling issues, its also super cheap to run!

Here a link on how to set one up https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website.

However if you want to use a custom domain, you’ll need to also use a CDN as well. This also allows you to set custom headers on your website, which is helpful so you can set security headers on, like you can with HelmetJS and Express. But it does mean there is a little increase in costs, but again its small and you only pay for what you use!


Azure Functions

This is the serverless API’s offering, it works very similar to Azure Web App offering. In my opinion this is the best dev experience out of all the cloud providers, its amazingly easy to get started and you can run the functions locally including all the cloud triggers as well. Here are the dev docs.

There’s also a VSCode plugin, where you can deploy functions, view existing functions and stream logs from any of your functions.

The functions also support for many languages and runtimes. Awesome for if you want to use a NodeJS version of your choosing, so you can use async/await for example.

There are loads of integrations across both the Azure and Microsoft ecosystems for example Office 365, Azure Cosmos DB, Twilio and SendGrid.

The cost is also great, as you would expect from a serverless offering, with 1 million invocations free per month!

I’m going to talk about logging and monitoring below as its by far and away the best experience I’ve seen from a cloud provider and is its own offering that can also be used for Web App’s etc.

Downsides

The downsides are pretty standard for serverless offerings, there’s always the issue of cold start times which can vary quite a lot I’ve found. And depending on your applications nature serverless might not be the right choice for you at this time. The integration with Azure B2C is okay, as you do get the user’s ID as a header but if you want further information you have to make another request and it would be nice if this was handled for you in the auth layer.

Azure Monitor

This is a series of tools that used to be separate but have recently been brought together under Azure Monitor.

This tool is amazing, simply plug either the lines of code from the docs or if your using one of the Azure services simply enable it and it will begin collecting pretty much all the metrics you could want! It will automatically detect where calls are made to, between servers or API’s and give you information about how many have failed, average time for a request and more, this lets you jump straight into seeing where the weak points are in your service or where a third party API is suffering.

You can collect your logs with it too, drill right down into the detailed stack traces or get a high level view by viewing the number of each log level. Using this for debugging is fantastic, once you’ve got an error you can view all the logs 5 minutes either side of the error which gives you a great picture across all your services or view the logs just for that request, it gives request a correlation id in Azure Functions for example, allowing you to really quickly debug what has happened.

You can also add Azure Monitor to you frontend applications so that you get a full overview of every part of you stack, from the frontend all the way through to your stack to the servers themselves. Not only can you collect the built in metrics but you can also collect custom metrics and information, and build your own visuals and dashboards with it too!

You can set up alerts on any metrics or log you want including any custom metrics you want, so if anything is going wrong you can jump on it straight away!

The pricing is also fantastic, it starts from totally free (including a free uptime checker) and you can set limits on collection so you don’t go over the free limits. But after the free allowance its not that expensive, and pays for itself in time spent debugging.

I cannot rate this highly enough, if you are running any application in Azure or not (you can totally use this with any application running anywhere) I would highly recommend checking out Azure Monitor!

Azure Authentication

I’ve only used Azure B2C as an auth provider, again serverless as you don’t need to manage anything yourselves. I’ve blogged about this in detail previously, check it out here.

That’s my experience with some of Azure’s serverless offerings, its one of my favourite cloud providers and one I’ve played around with most. Let me know what your experiences are, and get in touch if you want to chat about serverless any more! 😄

Discussion (0)

Forem Open with the Forem app