Build And Run Your Azure Function Locally Using Visual Studio 2019

What is Azure function ?

Azure function is a serverless compute offering of Microsoft Azure which lets you make event driven applications without worrying about the infrastructure management for the application. It is a Function as a Service offering (FaaS). You can write Azure functions in a variety of languages, ranging from C# to Java. This compute option asks you to pay depending upon  the code execution time of your code.

How to Build an Azure function using Visual Studio ?

Step 1
Open Visual Studio 2019 and Click on Create a new Project
Step 2
Now you need to select Azure Functions from the Project Templates available
Step 3
Configure the Project by giving it a project name and solution name. Also, if you want you can select the location where you want the solution files to be created.
Step 4
Now, select the Azure function runtime version, for this article I'm using V2. Then select the trigger type, storage account and Authorization of your Azure function. If you haven't decided with which trigger you want to make your Azure function then you can start with an Empty azure function. Authorization levels helps you to restrict the access to your Azure function from unwanted users.
Step 5
In the previous step, I had select the HttpTrigger as the Trigger Type for our Azure Function so once you click create in the screen of Step-4, Visual Studio will create the solution along with a default template for an Azure Function with HttpTrigger as Trigger Type. You can see the function name, the Http methods which your Azure function can take, the authorization type which you had selected earlier and a simple code to fetch data from the query string or request body whenever a request is sent to the zure function. Let's click on the MyFunctionApp button, besided Any CPU to run our Azure function. 
Step 6
After you click on the MyFunctionApp to run the Azure Function, you can see a window popup, which is the Azure Function core tool. This window will show us all the information about our Azure functions, starting from the URLs of our Azure functions, and requests and responses received and sent by them to the Logging information. 
Step 7
Let' scroll down a bit and the get URL of our Azure function which is http://localhost:7071/api/Function1, Let's copy this URL.
Step 8
Now let's open a browser and paste the Url and add a query string 'name' and click enter to send a request to our Azure function.
Step 9
And now you can see the respone provided by the Azure function in the browser screen as written in the code. You can alter the code and Play around to make the Azure function do what you want it to do.


This is a simple guide to develop and run an Azure function locally in your own system using Visual Studio 2019. There is more customization that you can do with it, like having custom routing, restricting the number Http methods that your function allows, changing the business logic of the azure function, adding dependecies to it and many more. And finally regarding Azure Functions Runtime Core tool, in my opnion it acts as server to host your Azure functions. Azure functions provide a simple and easy way to develop serverless applications in  the same way we typically make our web APIs or schedulers.