05
OctWhat is Serverless Computing? Exploring Azure Functions
Serverless Computing and Azure Functions
Serverless computing is one of the most coined terms in the cloud these days. Unleashing the PaaS feature with an immense amount compute power without any server to host an app has impacted web development in a big way. If we talk about Azure Functions, it is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs.
In this Azure Tutorial, We will explore more about Serverless Computing and Azure Functions including Monolithic Architecture, Azure Services, and detailed Azure Functions.
Breaking the Monolithic Architecture
- Earlier, we used to build one big application with a very complex architecture to maintain, which involved integrating all modules of an application that were tightly dependent on each other.
- Any failure on any of the modules was making the entire application go down.
- To resolve this issue, we moved on to segregating the modules into different services. This allows us to use different technology stacks for different microservices and deploy each of the microservices independently.
- Now, the number of microservices increased, and the challenge became to host different instances of microservices on multiple servers to keep the application running.
- Serverless computing helps us mitigate such issues by using Azure Functions as we have only functions that take care of different modules interacting with third-party services like cognitive services or Sigle sign-on services, Graph and chart image services, etc.
- Cloud service providers manage to identify and allocate resources dynamically rather than pre-provisioning a set of virtual blocks of the resource with some limited set of computing power. And that’s how Serverless compute modules can be scaled on runtime.
Azure Services based on Server-less Architecture
Microsoft offers the below Azure services to facilitate Serverless computing-
Serverless Coding
Azure functions are event-triggered pieces of code with logic to perform a specific task by connecting to different Azure or third-party services. Compute power and resources are utilized only when the function executes. We only need to pay per request to the function.
Storage
Azure Storage is a highly reliable and scalable service that can be used to store structured or unstructured data. It connects with other Azure services seamlessly and can act as a third-party data source for images, videos, or any other content
Database
Azure Cosmos DB can act as a third-party data source service. Azure functions can connect to Cosmos DB and can read data to process. The important feature of cosmos DB is it can replicate to a different region with the highly scalable option to provide low latency.
Sign In
Azure AD can be used as a login service to connect with cloud-based identity and access management. All user data and roles can be managed via Azure AD user management.
Messaging
Azure Service Bus is a messaging service that processes data in an order. We can use Queues or Topics to ensure that every message that comes in the pipeline is processed. This can be used as a fully managed messaging service provider.
Workflow
Azure logic apps are used to orchestrate functional workflows by integrating various Azure and third-party services to connect data to the apps.
Intelligence
Cognitive services like vision and speech recognition, language detection, and emotion and sentiment detection help to add artificial intelligence to the application.
Azure Functions
- Azure functions are serverless compute modal element that runs code on demand and without the need for hosting it on a server.
- This also frees us from any complexity in application architecture, as we only write the code required to perform a specific task.
Key Features of Azure Functions
Independent Module—Functions can be developed as independent modules. We can import NuGet libraries and use them to build small but robust applications. These can then be further integrated into other applications or workflows.
Pay per use - Unlike other PaaS Services where a dedicated amount of resources and compute power is charged with the Azure App Service plan, Azure functions are charged on the basis of the number of times it run.
Language Choice—Azure supports Functions written in various languages, such as C#, F#, Node.js, PHP, or Java.
Security - HTTPTriggered Functions can be secured using OAuth Identity Providers such as Azure AD. The token generated using AD can be passed into the HTTP request header which can be validated in the code.
Easy Development—We don’t even need to write code in an IDE. We can directly write code in the Azure portal and test it or set up continuous integration and deploy code through VSTS and GitHub.
Creating Azure Function Application
Click on Create a Resource on the Azure portal.
Select the Compute option from the marketplace and click on the Function app.
Provide the function app name, resource group, hosting plan, and storage account details, and click Create.
Check on the Notification icon at the top right corner and click on the Go to Resource button.
Click on the add (+) symbol to add an Azure function.
A HTTP trigger function with some default code is created. We can test the app by clicking on the Run button and passing some text as the input body of the request.
Uses of Azure Functions
Data Processing through connected services. When a new file is uploaded into blob storage some specific processing is required.
Triggering a chain event on some event on some connected Azure Service like when a new message arrives on a queue.
They can also act as middleware between different services in a microservice architecture.
Azure Function Pricing
Azure Functions can be hosted with two different kinds of pricing
Consumption plan
It provides all necessary resources to the function app dynamically and will charge only when the function runs.
App Service plan
If you are already using an app service plan for other app services, such as a web app or API app, the same hosting plan can be used here at no extra cost. You will be charged only for the number of times the function app executes.
Limitations
Lack of Troubleshooting methods—It's difficult to identify an issue in production since there is no way to debug a function. Azure provides an app insights feature by default with the Azure function to help analyze the logs.
Third-Party API Trust—Since Serverless computing heavily relies on third-party services, we need to trust their response and security.
Vendor Locking—Outbound requests may also be expected to return quickly, which can be further processed. Any lock state in third-party services will cause delay and unexpected behavior.
Overly Complex Architecture—Too many functions in an application may also result in a very complex architecture that is difficult to manage.
Latency—The initial booting time and latency over the network caused by hoping from one function to another increase latencies and may impact the SLAs.
Summary
Serverless is a style of architecture in which we do not worry about hosting the application or the required infrastructure to make the app run. Azure functions are Serverless and lightweight, and writing and deploying them is simpler. Scholarhat Azure online training is delivered by Microsoft MVP Mr. Shailendra to help you earn Azure real-time focused Hands-on skills and get Azure certification.
FAQs
Q1. What is the concept of Azure Functions?
Q2. How many types of Azure Functions are there?
Q3. Is Azure Functions IAAs or PaaS?
Take our Azure skill challenge to evaluate yourself!
In less than 5 minutes, with our skill challenge, you can identify your knowledge gaps and strengths in a given skill.