Wednesday, August 19, 2020

What is Azure Function

Azure Functions allows you to run small pieces of code (called "functions") without worrying about application infrastructure. With Azure Functions, the cloud infrastructure provides all the up-to-date servers you need to keep your application running at scale. These functions are invoked when a client makes an HTTP request.

The most important feature introduced by Functions was on-demand scaling and pricing, called the Consumption Plan. With the Consumption Plan, a function can be running on up to 100 server nodes in parallel, and it auto-scales depending on load. You only pay for usage. It’s a fully serverless Function-as-a-Service (FaaS). This means you get a more scalable service at a lower price. You can also run Functions on an App Service Plan, but that’s not its main selling point.

How Azure Function Work

Azure functions are event driven actions. Triggers are what cause a function to run. A trigger defines how a function is invoked and a function must have exactly one trigger. Anything that triggers an Azure Function to execute is regarded by the Framework as an Event. Events are platform events on Azure Functions

1.       HTTP Trigger (REST API)

2.       Scheduled timer (Run every 5 minutes)

3.       Service Bus Queue trigger (A work item from another Function)

4.       IoT/Event Hub message (A message from a device or service)

5.       Webhook fires (GitHub project update)

Based on above events our azure function run. You have to select the event trigger on which you want to execute your azure function code.

         Azure Function=  Event + Code

When any event occurred is occurred then code will run 

How many Azure Function

When we create new azure function in azure it creates 3 essential components. Which required to run the function

1.       App Service Plan (Function require compute power to host)

2.       Storage Account (Function need some type of storage for operations)

3.       Runtime scaling (Function scale up and down as per demand)

App Service plan

Azure Functions infrastructure scales CPU and memory resources by adding additional instances of the Functions host, based on the number of events that its functions are triggered on. Each instance of the Functions host in the Consumption plan is limited to 1.5 GB of memory and one CPU. An instance of the host is the entire function app, meaning all functions within a function app share resource within an instance and scale at the same time. Function apps that share the same Consumption plan are scaled independently.

If you want to learn more about App service Plan read my previous blog Azure Services and Apps

Storage account

Azure function app requires a general Azure Storage account, which supports Azure Blob, Queue, Files, and Table storage. This is because Azure Functions relies on Azure Storage for operations such as managing triggers and logging function executions

Runtime scaling

Azure Functions uses a component called the scale controller to monitor the rate of events and determine whether to scale out or scale in. The scale controller uses heuristics for each trigger type.

How to create azure function

When we create azure function with help of azure portal. Then we need to give the azure function a name and set which programming language (runtime) in which we will write our function code. I have chosen below options click in next for Hosting configuration.

Once we select all above options then we need to define Hosting configuration for azure function like Storage account and App Service Plan.

Once we click on create button with all these options our azure function will create. In this case my azure function.


Once azure function URL created no we need to add function on it like below screen adding HTTP trigger

Click on create function our Demo function will Scaffolding demo code for us. We can update the code as per our requirement. It will look like below

Function URL:

As you can see in above code it requires “name” as query string parameter from HTTP request. If you call this below URL it will give this output

Request URL:


Here one you tube video created by Microsoft for Azure Functions Overview it will help you to understand it.

In future post we will work on some complex azure function logic, for now I hope it will help you to understand azure functions

Keep sharing keep learning

1 comment:

  1. They offer numerous site facilitating arrangements, like region stopping and email facilitating, all out there underneath various plans customized to fulfill your facilitating needs.