
In this Azure tutorial, we will discuss How To Create Azure Functions .Net Core Version.
Table of Contents
How To Create Azure Functions .Net Core Version
Well, here we will discuss How To Create Azure Functions .Net Core Version. Before starting the actual development, we should know what are the prerequisites.
Prerequisites
- we need an Azure Account or Azure Subscription. No Azure Account till now? Don’t worry. create an Azure Free Account now.
- Visual Studio 2019 with Azure development workload installed. Install Visual Studio 2019 now in case you don’t have Visual Studio 2019 installed in your local machine.
- An Azure Storage Account. No Azure Storage Account till now, create an Azure Storage Account now.
Now, follow the below steps for Creating an Azure Functions .Net Core Version in Visual Studio 2019. So we will use the latest version of VS (Visual Studio 2019) for our development activities. As part of the development activity, we will create the Azure Function first, and then We will check if the Azure Function is working locally.
Step-1: Open the Visual Studio 2019.

Step-2: Click on the Create a new project button from the Get Started window.

Step-3: Choose the Azure Functions as the project template On the Create a new project window, then click on the Next button to go to the next window.

Step-4: Provide a Project name, Choose a Project location where you want to save your project, and then click on the Create button on the below Configure Your New Project Window.

Step-5: Choose the Empty Option On the Create a new Azure Functions Application window and then click on the Create button.

Step-6: The project will create successfully. Now right-click on the Project and click on the Properties option.

Step-7: Now, on the Project Properties window, Choose the Target Framework as .Net Core 3.1 and then click on the Save button to save the changes.

Step-8: Now Rebuild the Project once and since it is an empty project there is no class as of now. Add a class and add the Azure Function code there
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace MyDemoASPNETCore
{
class MyFunction
{
[FunctionName("MyNewFunction")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
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)
? "Function executed successfully. Pass a name in the query string."
: $"Hello, {name}. Azure function executed successfully.";
return new OkObjectResult(responseMessage);
}
}
}

Step-9: Now run the Project by pressing the F5 button to check if the function is working as expected. Now you can see, It ran successfully without any issues.
The Function URL is shown below
MyNewFunction: [GET,POST] http://localhost:7071/api/MyNewFunction

Step-10: Now we will test the Azure Function locally, If it is working fine, Now copy the Function URL, Open your Favorite Browser, and try accessing the function URL. Now you can see it. It is asking us to provide a name value as the query string parameter.

Step-11: Now let’s append the name value as a query string parameter and try executing the function URL. http://localhost:7071/api/MyNewFunction?name=AzureLessons
You can see below, we got the expected output.

Tools in Visual Studio Code.
You may also like following the below Articles
- How To Use Automapper In Azure Functions
- There is no Functions runtime available that matches the version specified in the project
- Azure Functions Core Tools | How to Install
Conclusion
Well, in this article, we have discussed How To Create Azure Functions .Net Core Version. Thanks for reading this article !!!