Azure Functions is a serverless concept of cloud-native design that allows a piece of code to be deployed and executed without needing server infrastructure, web server, or any configurations. In addition, azure functions can be written in multiple languages such as C#, Java, JavaScript, TypeScript, and Python.
This article explains what an azure function is, how to create an azure function, and how to debug, test, and deploy azure functions.
Azure functions are scalable. When demand for execution increases, more resources are allocated automatically to the service, and when requests fall, all extra resources and application instances drop off automatically.

Let's say you have to send a birthday email to your customers. You're an ASP.NET web developer. Instead of building a website in ASP.NET and employing and hosting it on IIS just for one feature, you can write an azure function, put your email login in the function, and deploy it on the Azure cloud. The azure functions will directly connect to your data source, get your customers' emails, and send them an email on a scheduled date and time.
Azure functions are best suited for smaller apps with events that can work independently of other websites. For example, some azure functions are sending emails, starting back up, order processing, task scheduling such as database cleanup, sending notifications, messages, and IoT data processing.
Why use Azure Functions
Here are some of the reasons why you should use azure functions.
- Azure functions are lightweight and serverless.
- Azure functions are easier to write and deploy.
- Azure functions are fast to execute because there is no large application, startup time, initialization, and other events fired before the code is executed.
- Azure functions' execution is triggered when an event is fired.
- Azure functions are compute-on-demand, and that is scalable. When the demand for the execution increases, more resources are allocated automatically to the service, and when requests fall, all extra resources and application instances drop off automatically.
- Azure functions support programming languages, including ding C#, F#, Java, JavaScript, TypeScript, and Python. You choose your choice of language.
- Azure functions do not need any infrastructure and have 0 maintenance.
- The azure function can be built, tested, and deployed in the Azure portal using a browser.
- Azure functions are easy to upgrade and don't affect other parts of the website.
- Azure functions use industry standards and can communicate with other APIs, databases, and libraries.
Create an Azure Functions using Visual Studio 2019
Before we go too far, let's create Azure Functions using Visual Studio 2019.
Open your Visual Studio 2019 and create a new project.
On the new project template page, search for azure functions and see a template for Azure Functions. See below.

Select the Azure Functions template and click Next.
On the below screen, you need to give your functions application a name and select a location where the VS project is goiwille.

You may also see from the above screen that the function is created using C# and have Ahas and Cloud tags means, which will be deployed and run on Azure cloud.
Click Create button.
On the next screen, we need to select what kind of application it will be. Azure functions have this concept of triggers. A trigger is what causes a function to run. Each function has precisely one trigger.
Let's take a look at the below screen that shows various triggers available in Visual Studio for an Azure functions app.

As you can see, each trigger has its spic purpose.
For now, let us select Http Trigger that is executed whenever an HTTP request is made.
Click on Create button to create our app.
We land in Visual Studio with a default file, Function1.cs, and the default function code.

Here is the complete code of my function.
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace HelloFunction {
public static class Function1 {
[FunctionName("Function1")]
public static async Task < IActionResult > Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) {
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
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 new OkObjectResult(responseMessage);
}
}
}
That was the default code of our Azure functions.
Now, let's build and execute it.
Visual Studio provides an Azure Storage emulator to run and test azure functions locally.
Build and Run the application using F5.
You will see the Azure Storage emulator is being started.

The next screen will be func.exe show, ng this message that your function is ready and can be used.

As you can see from the above screen, the Azure functions, Function 1 has GET, POST and the URL is http://localhost:7071/api/Function1. This is the URL you can use to execute the function.
Let's type this URL in our local browser and pass a query string with a value. Then, the output looks like the following: the function takes the query string input and displays it on the screen.

That is all. You just completed the Hello Azure Functions application.
Publish Azure Function to Azure
You can publish directly h your Azure functions app now in Visual Studio or Visual Studio Code.
In my Visual Studio project, right-click on the project name and select Publish.
It will launch the Publish screen, where you may select Azure, Docker, or other folders where you may wish to deploy your app.
In our case, I select Azure.












Tahir AnsariPosted Jul 27, 2023, 9:46 AM
As a beginner in Azure Functions, I am confident that this knowledge will greatly benefit me. Thank you, Mahesh sir, for your invaluable assistance!
Muhammad Imran AnsariPosted Nov 29, 2022, 6:36 PM
Very nice article with deep insights.
Koshila SenadhiraPosted Nov 29, 2022, 7:30 AM
Very useful information! It was very helpful to career growth!
Jaydeep PatilPosted Aug 24, 2022, 6:09 PM
Very Helpful
Sarath BaijuPosted Jan 26, 2022, 5:03 PM
Do you know how the request handling pipeline works in a azure function application?
sai jamesPosted Aug 7, 2021, 1:15 PM
Excellent Article Mahesh Sir. it is very helpful to me.
Abhinav JainPosted Jul 15, 2021, 9:26 AM
Hi Mahesh, Great article about Azure function. Found it very useful. You have covered all the point of Azure function. If you can include - Ways to connect to Azure functions with details (Like from C#, JS etc ) then it will be perfect.
Vishal KadamPosted Mar 26, 2021, 7:31 AM
It just took me only 30 min to say that " I have worked on Azure Functions and created POC" just because of your article sir. Thank you!
Vinay AyinapurapuPosted Mar 24, 2021, 10:48 PM
You are setting a trend to publish an article. Thank you for valuable article. A must read for users who wants to start or already working on Functions.
Sagar SamalPosted Feb 14, 2021, 5:38 PM
Very Helpful Sir!!!. Thanks
Arkadeep DePosted Feb 11, 2021, 9:10 AM
Nice.. helpful for all
Pritesh MaturkarPosted Feb 10, 2021, 8:34 AM
Very Nice Sir. it is very helpful. Thank you.
Hamid KhanPosted Feb 6, 2021, 5:29 PM
Very very Helpful................