Azure Functions Overview

prem murmu on 9/16/2020 3:08:30 PM

When we say serverless computing,right thing will be the Azure Functions. It is a modern serverless architecture delivering event driven cloud computing.

In Azure function we can run small pieces of code (called "functions") without worrying about application infrastructure. Or Azure Function is a serverless compute service that enables user to run event-triggered code without having to provision or manage infrastructure.

With Azure Functions, the cloud infrastructure provides all the up-to-date servers It can even be scaled according to demand. To build the apps themselves, the developers can use their own choice of programming language, giving them the freedom to work optimally.


A function is "triggered" by a specific type of event. Supported triggers include responding to changes in data, responding to messages, running on a schedule, or as the result of an HTTP request.

Azure function code Example.

// This is HTTP Trigger function,Lets try to understand code

#r "Newtonsoft.Json"    // to reference external assembly ,Use #r 

using System.Net;

using Microsoft.AspNetCore.Mvc;

using Microsoft.Extensions.Primitives;

using Newtonsoft.Json;


// HttpRequest  object will contain methods(get,post ),Header and body informations

//ILogger is to log to activity in function

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)

{

    log.LogInformation("C# HTTP trigger function processed a request.");

  //fecthing the request querystring parameter

    string name = req.Query["name"];

  //Below three line to read the requestbody

//ReadToEndAsync read all data from the requestbody

    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();

 //DeserializeObject to get the Json object

    dynamic data = JsonConvert.DeserializeObject(requestBody);

 //Get the name from data object

    name = name ?? data?.name;

    string responseMessage = string.IsNullOrEmpty(name) ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response." : $"Hello, {name}. This HTTP triggered function executed successfully.";

//Return http result

            return new OkObjectResult(responseMessage);

}

Key features of Azure Functions:


Serverless applications: Functions allow you to develop serverless applications on Microsoft Azure.

Choice of language: Write functions using your choice of C#, Java, JavaScript, Python, and PowerShell.

Pay-per-use pricing model: Pay only for the time spent running your code. See the Consumption hosting plan option in the pricing section.

Bring your own dependencies: Functions supports NuGet and NPM, giving you access to your favorite libraries.

Integrated security: Protect HTTP-triggered functions with OAuth providers such as Azure Active Directory, Facebook, Google, Twitter, and Microsoft Account.

Simplified integration: Easily integrate with Azure services and software-as-a-service (SaaS) offerings.

Flexible development: Set up continuous integration and deploy your code through GitHub, Azure DevOps Services, and other supported development tools.

Stateful serverless architecture: Orchestrate serverless applications with Durable Functions.

Open-source: The Functions runtime is open-source and available on GitHub.

Type of Functions and its triggers templates

Functions is a great solution for processing bulk data, integrating systems, working with the internet-of-things (IoT), and building simple APIs and micro-services.
A series of azure funnction triggers templates is available to get you started with key scenarios including:

HTTP:

Run code based on HTTP requests

Timer:

Schedule code to run at predefined times

Azure Cosmos DB:

Process new and modified Azure Cosmos DB documents

Blob storage:

Process new and modified Azure Storage blobs

Queue storage:

Respond to Azure Storage queue messages

Event Grid:

Respond to Azure Event Grid events via subscriptions and filters

Event Hub:

Respond to high-volumes of Azure Event Hub events.

Service Bus Queue:

Connect to other Azure or on-premises services by responding Service Bus queue messages

Service Bus Topic:

Connect other Azure services or on-premises services by responding to Service Bus topic messages

Azure Functions pricing plans:

Azure Functions has three kinds of pricing plans. you canchoose the one that best fits your needs:

Consumption plan:

Azure provides all of the necessary computational resources. You don't have to worry about resource management, and only pay for the time that your code runs.

Premium plan:

You specify a number of pre-warmed instances that are always online and ready to immediately respond. When your function runs, Azure provides any additional computational resources that are needed. You pay for the pre-warmed instances running continuously and any additional instances you use as Azure scales your app in and out.

App Service plan:

Run your functions just like your web apps. If you use App Service for your other applications, your functions can run on the same plan at no additional cost.

...
Best Hosting plans

0 Comments on this post

Comments(0)||Login to Comments


InterServer Web Hosting and VPS
  • see more..