Azure Serverless Functions

Azures functions are known as FaaS “Functions as a Service”. In this article, we will learn about Azure Serverless Functions.

Introduction

 
Azures Functions are known as FaaS - “Function-as-a-Service”. This means that our code can be executed/responded to an event. Functions support many languages, like C#, JavaScript, etc. and can be scaled automatically.
 
Azure Serverless Functions

Triggers

 
Each function is run when something happens on it, that is called a trigger and the same can be categorized into the following categories.
  • Timer –run based on a schedule
  • Message – listen for a message on a queue
  • HTTP Request –by making Web API (get, put, delete) or webhooks call
  • Blog storage – when we get any modification on the storage then we can trigger a function

Functions support Serverless Architecture - This means that Azure can manage the servers for us. We do not need to worry about patching and maintaining it.

Functions offer per-second billing model which means we only pay for what we consume. On the other hand, functions come up with a monthly free grant, it allows the use of some defined transaction limits per month and we should pay only if we exceed the limit.
 
With auto scale, if we get a thousand requests in one time, then it has no need to wait to execute on the single server. This means that behind the scenes, Azure can automatically bring up multiple servers to handle a large amount of requests.

For Hosting Models, we have three major categories.

  • Consumption Plan (serverless) –per-second billing or monthly grant
  • App Service Plan – reserved servers or predictable monthly cost
  • Docker Container – runs under docker

Development Environment

  • For Azure portal, you can log in here and create the functions, if you want to do a demo or POC, then you go for it. With this type, you can create the function in very minimal time.
  • Visual Studio 2017 – this powerful tool comes with extensions to support Azure functions. It allows debugging and testing locally of our functions.
  • Visual Studio Code – it comes with a command line tool to connect Azure function tools. It does not require Visual Studio 2017 and it supports cross-platform, for example, if you want to create JavaScript functions in Mac / Linux OS, then it is a great choice to use Visual Studio Code. It’s a free ,open source and its support cross platform text editor. Even it would allow debug and test functions locally

Additional Features

  • Security – when we create the HTTP-request functions, by default azure is creating a secret API key that allows us to protect our Azure functions. It enables identity integration; i.e., you are authenticated by Azure active directory in order to use functions.
  • Durable functions - define workflow , run tasks in parallel , retriggering and error loggings
  • Proxy – It allows us to route specific functions in our application or even route to other locations

Functions Apps support the following things:

  • Unit of deployment 
  • Common configuring
  • Scaling together