Serverless Compute Service and Azure Functions – an Introduction


Serverless Azure Functions

Serverless Computing - Introduction


Once we talk about serverless in the Azure cloud, it means time to focus on business logic in reference to the application rather than looking the infrastructure management. No doubt, nowadays serverless is a buzzword, actually the serverless compute automatically scale up and down your apps based on the number of incoming events. It makes you think less about the servers that you are pushing your code on, in other words, no need to worry about hardware, software or any that type of bits & pieces. 

Building a serverless application allows you to focus on your application code instead of managing and operating infrastructure. Let’s consider an example, just think about wireless router in your home. It doesn’t have any wires, it plugged into something. Interestingly, you are just worried about connection or how to consume the service rather than thinking about it’s wired or all hardware etc. Similarly, we can correlate this with the serverles computing service, by using serverless application no need to worry about the software and hardware at all. Only consider the code and there is somewhere I can send my code that it can run and it will scale automatically. 

Serverless Computing


Serverless computing is an event-driven application design and deployment model in near-real time , which computing resources are provided as scalable cloud services. It is the abstraction of servers, infrastructure and operating systems. Precisely, it resembles a faster time to market with lower infrastructure and operating costs.

Consider an e-commerce online example, a web application backend which is powered by serverless architecture. Here online orders are picked up from a queue, processes and the resulting data is stored in a database.

Serverless e-commerce application


Advantages of Serverless Computing


Serverless as it sounds, it doesn't really mean that servers are out of the picture, serverless means there is no server you need to worry about. In fact, you do not know which server it eventually runs on. Once your code is deployed, Azure itself assigns the responsibility of executing the code to the next available server. What Azure ensures, and that  is ultimately important for developers, that code will execute whenever required.

There are plenty of reasons to opt serverless computing, let’s see the following key advantages of Serverless Computing– 

No administration

As we are talking about serverless architecture, with no physical hardware or virtual servers, leads to no administration. Thus, no administration means, no relevant costs and more importantly no administration failures.
Though serverless compute service does actually take place on servers, but developers never have to contract with the servers. Cloud providers are going to manage all those back-end servers and orchestration.

Enhanced Scalability

An application is considered scalable if it is enough capable to handle an increased peak load and manage the demand. Provisioning infrastructure for such high demand is not feasible always, it would be risky at all times. Supossed enough hardware or virtual machines has been set up during the peak duration, but in off peak season this capacity is not used and still generates costs.
If I talk about about serverless, scalability is no longer a problem, as you can scale horizontally as much you required. Applications built with a serverless infrastructure will scale automatically as the request increase as well it can process a single request from a single user.  

Lower cost 

In the context of computing power as well human resource (HR), serverless compute service will anytime save. Let’s consider a scenario, if the application is running on hardware, servers, you will have to procure the infrastructures and manage relevant segments like, premises, electricity, cooling, maintenance staffs etc. that lead to the expensive cost. 

If you go with serverless architecture, it can help to reduce the infrastructure cost more, because the application components will be running on multiple servers and consuming only as much computing power is required. Irrespective of cloud computing (e.g. Virtual Machines), no charges for idle time, just pay for the resources you actually use.
In contrast, in a traditional 'server-full' architecture, developers have to project in advance how much server capacity required and then procure that capacity, whether they end up using it or not.

Improved Productivity

Once you see that serverless having major benefit in scalability as well reducing the cost then other reasonable advantages synced-up, that company will see is around developer efficiency. Now developer will focus to compose the code rather than investing energy to manage and operate the framework. Holistically, engineers will spend healthy time in agile development and will concentrate on code and deliver quickly.

Undoubtedly, using a serverless infrastructure, there is no need to engage more in uploading codes to servers or back-end configuration to release the build. Developers can very quickly uploads bits of code and release a new version as can update, patch or add new features to an application.

Faster time to market

One of the added benefit of serverless approach, it decreased time to market and faster software release. It allows developers to create new apps in hours and days instead of weeks and months. Therefore, end product takes less time, so giving the company an additional competitive advantage. 

Improved latency and Geo-location

If I talk about the capacity to scale of an application, most probably depends on the number of users, user’s location and the network latency. Certainly the latency, or the time of application response, is one of the critical issues which can affect its performance. However, latency greatly depends on the physical geography, the distance to the data center. 

In the context of shortest possible response time, serverless makes guarantee because provider usually ensures global coverage and presence. Since cloud providers have points of presence close to each client’s geography and thus applications perform equally well for everybody.

Advantages of Serverless Computing

Azure - Serverless Components


Now we have came to know, serverless ideally reduces infrastructure to zero. It takes the stress and worry about application scaling off your hands. Indeed, there is really a server, but it’s not yours and there is no hint of its existence though the application is running. We went through the distinguished quality of serverless as – 
  • Abstraction of servers
  • Event-driven start-up triggers/instant scale out or in.
  • Micro-billing instead of per-hour/month billing.


In the perspective of Azure serverless components, following are the key serverless application platform components -  
  1. Functions – You can execute your code that is based on events you specify.
  2. Logic Apps – Precisely a workflow made up different steps and orchestrate processes, it ties together different things inside and outside of Azure in a workflow.
  3. Event Grid – Relatively a new service, manages all events that can trigger code or logic.


Serverless Components


Here we are going to explore more about the Azure Functions, which is an event-driven compute experience that allows you to execute your code, written in the programming language of your choice, without worrying about servers.

Azure Functions – Introduction 


Azure Functions essentially are a merger of code and events that build apps faster with a serverless architecture. It is a serverless compute service that enables you to run code on on-demand without having an explicit provision or manage infrastructure hassle. 

Once we talk about serverless, it means the code is running essentially in this platform and it is waiting for execution orders. Azure Function allows us to do this by having these things called the triggers and binding. By using Azure Functions you can execute a script or piece of code in response to a variety of events and you don’t have to worry about the infrastructure of the platform on which it is executed.

Azure Functions

In brief, Azure Functions allow you to build applications built on serverless architecture using functions called by various triggers like, HTTP request, queue, etc. Thus, Function-as-a-Service (FaaS) turned a generic term for such serverless necessitates, to build the apps themselves, the developers can use their own choice of programming language such as C#, F#, Node.js, Java, or PHP.

Azure Functions – Features


Simply, Azure Functions enables you execute your code in a serverless environment without having to first create a VM or publish a web application. You can leverage Azure Functions better due to it’s various key features – 
  • Choice of language – You are free to choose the programming language as per your choice and feasibility. It accepts a variety of programming languages like C#, F#, Node.js, Python, PHP or Java.
  • Pay-as-you-use model – By using serverless architecture, no need to worry about the resource management. You will have to pay only for the consumed time the code is run, gives the freedom to scale up and down as per need.
  • Easy integration – Azure Functions serves integration with a number of Azure services as well several third-party services. It supports NuGet so you can use desired libraries along with different Azure services.
  • Security concerns – It protects HTTP-triggered functions with OAuth providers such as the Azure Active Directory, Facebook, Google, Twitter, and Microsoft Account.
  • Flexible development – Although, Azure Function is a serverless architecture, it still supports Continuous Deployment and Continuous Integration. You can do this through GitHub, MS Visual Studio and other tools like, Xcode and Eclipse etc.
  • Custom features – It is easier to implement custom features with this platform because the Functions run-time is open-source and available on GitHub.


Azure Function features


Azure Functions – Ready-made Templates


Functions are a great solution for processing data, integrating systems, working with the IoT, and building simple APIs as well micro-services. Azure Functions have various ready-made templates containing a set of pre-defined functions that showcase a working scenario. It acts as a repository where you can move ahead to perform more complex functions, some of them – 
  • HTTPTrigger – It supports HTTP request, through which you can execute your code accordingly.
  • TimerTrigger – It supports schedule, through which you can can execute events or batch tasks.
  • CosmosDBTrigger – It supports trigger, input binding and output bindings for Azure Cosmos DB.
  • BlobTrigger – Using this template, you can trigger a function when a blob is created or updated to a container.
  • QueueTrigger – It helps to trigger a function when a new update comes up in the queue.
  • EventGridTrigger – It supports a subscription-based model for receiving events, responding to events delivered to a subscription in the Azure Event Grid.
  • EventHubTrigger – It responds to events delivered to an Azure Event Hub, useful in application instrument, IoT scenarios, etc. It provides support for trigger and output bindings for Event Hubs.
  • ServiceBusQueueTrigger – Using this trigger, the developer can execute the code in the function every time the service bus received a message.
  • ServiceBusTopicTrigger - When the function is triggered by service bus topic message, the developer can publish and push messages to the topic.


Azure Functions Templates

Azure Functions trigger outlines on how an Azure Function should be invoked by executing your code. In Azure,a function must have exactly one trigger. Triggers in Azure Function have data, and that is usually the payload that invokes the Azure Function.

Binding to a function is a declarative way of sending and receiving data from an Azure Function. Bindings for Azure Functions are optional, it may be connected as input bindings, output bindings, or both input and output. Data from bindings is provided to the function as parameters.

Azure Functions – Integrations


Azure Functions integrate with a number of third-party services, on-premises services and several Azure services to trigger, the functions or serve as input/output for the code. Azure Functions support the following service integrations – 
  • Azure Cosmos DB
  • Azure Event Hubs
  • Azure Event Grid
  • Azure Notification Hubs
  • Azure Service Bus (queues and topics)
  • Azure Storage (blob, queues and tables)
  • On-premises (using Service Bus)
  • Twilio (SMS messages)


It is possible to monitor and troubleshoot functions with the logging capabilities provided within this compute-on demand, event driven experience.

In a conclusion, Azure Functions are designed to speed up the process of application development and make it quick and simple. Certainly the Cloud computing improved a lot of things, but with serverless computing, it is likely to stop worrying about all the infrastructure considerations you once faced, and just focus on creating and uploading the proper code. Defining the triggers and events that will execute the code can follow this. The trigger could be from anywhere - another user’s application, Notification Hubs, other cloud services etc.

In the next couple of posts we will leverage Azure Function by using some hands on activities, keep visiting the blog.







No comments:

Post a Comment