What is Azure Function?

Azure Functions is an event-driven, serverless compute platform used to run snippets of code in Azure. Azure Functions provide flexibility in deploying applications and creating automation. If you are modernizing your application from on-premises server

What is Serverless Computing?

Serverless computing hosts and runs code in the cloud. You do not need to install or maintain servers to run code.

When to use Azure Functions?

Prerequisites

Make sure we have Azure subscription. (We used free trial subscription)

Visual Studio [ Community | Professional | Enterprise] with Azure development

Azure Function

Now lets login into Azure portal, and click on Function app

Azure Function

It will show the below screen, where we don’t have any function app.

Let's create it by clicking on Create option in top menu

Azure Function

Specify Function app name and other configurations as per below screen.

Azure Function

Once you create Function app in azure portal deployment screen will be appearing. Let's wait till finishes the process

Azure Function

We can now add Function trigger, with azure portal

Azure Function

But at moment I will not add functions through azure portal but we will create from Visual Studio and will deploy to azure.

Open Visual Studio and create new Project of Azure Functions Template

Azure Function

Specify Project name

Azure Function

Choose .Net 6.0 as Function Worker

Choose Http trigger

Azure Function

Now you can see Solution explorer and find FunctionApp1 project has been created

Publish Azure Function From Visual Studio:

Right click on Azure FunctionApp Project and click on Publish.

Azure Function

Azure Function

Azure Function

If you have not logged in to Azure account then you need to login, once you logged in then we can now able to see Azure App which we created from Portal.

Click Finish to Complete Publish Profile. And click on Publish option

Once Publishing is Finished then check on Azure Portal

Now, we should have Function1 in Azure portal.

Run /Test Functions:

Click on Function1

Azure Function

Click on Get Function URL option and Copy Function URL

Azure Function

Now let's call this API request from browser

Azure Function

It says that we need to pass query string parameter named as 'name' so let's pass the parameter and its value

Azure Function

Yahoo, we are able to see API Response.