Azure Functions .Net Core Version How To Create

Azure Functions .Net Core Version How To Create

In this Azure tutorial, we will discuss Azure Functions .Net Core Version How To Create. Along with this, we will also discuss the below topics.

  • There Is No Functions Runtime Available That Matches The Version Specified In The Project
  • Azure Functions c#
  • Azure Functions Core Tools
  • Azure Functions Core Tools Installation
  • Install Azure Functions Core Tools in Visual Studio 2019
  • Install Azure Functions Core Tools in Visual Studio Code

Azure Functions .Net Core Version How To Create

Well, here we will discuss Azure Functions .Net Core Version How To Create. 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.

How To Create Azure Functions In Visual Studio

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

How To Create Azure Functions In Visual Studio 2019

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

Develop And Deploy Azure Function Using Visual Studio

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.

How To Create Azure Functions .Net Core Version

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

How To Create Azure Functions .Net Core Version Visual Studio 2019

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

How To Create Azure Functions .Net Core using Version Visual Studio 2019

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.

 How To Create Azure Functions .Net Core in Version Visual Studio 2019

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);
        }
    }
}
Azure Functions .Net Core Version

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 with out any issue.

The Function URL is as shown below

MyNewFunction: [GET,POST] http://localhost:7071/api/MyNewFunction

Develop Azure Functions using .NET Core 3.1

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.

Develop Functions with .NET Core Runtime 3.1

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.

develop azure functions using .net core 3.1 visual studio

This is all about the Azure Functions .Net Core Version How To Create.

There Is No Functions Runtime Available That Matches The Version Specified In The Project

Some times back, I have Created one Azure Function project. The project got created Successfully without any issue but when I Just Press F5 to run the project, immediately I got the below Error.

There is no Functions runtime available that matches the version specified in the project

There is no Functions runtime available that matches the version specified in the project

Now to fix this, I have tried multiple ways but nothing worked for me. So Finally what I did is I have Updated the Visual Studio 2019 Version to the latest version and that fixed my issue. After that, I was able to run the project without any issue.

This is how I was able to fix the error ” There Is No Functions Runtime Available That Matches The Version Specified In The Project “.

Azure Functions c#

Before Starting the Azure Functions C#, Assuming, you have some idea on Azure Function. Follow the below steps.

Login to the  Azure Portal (https://portal.azure.com/)

Once, login to the Portal, search for the Function App and then click on the Search result.

azure functions c 1

Now, On the Function App window, click on the + Add button to create the new function App.

Azure Functions using c#

On the Create Function App window, Provide the below Details.

On the Basics Tab, you will have to Provide the below details

  • Subscription: Select your Azure Subscription.
  • Resource Group: You can either choose your existing Resource Group or If you do not have a Resource Group, you can create a new Resource Group by clicking on the Create new link.
  • Function App name: Provide a unique name for your Azure function App.
  • Publish: Choose the Code option for this.
  • Runtime stack: Choose the .NET Core for this option.
  • Version: Choose the version as 3.1.
  • Region: Choose the Region for your Azure Function App.

Now, click on the Next : Hosting > button to go to the Hosting tab.

Azure Functions using c# Azure Portal

Now on the Hosting tab, provide the below details

  • Storage account: Choose your existing Storage Account or you can create a new storage account by clicking on the Create new button.
  • Operating System: Choose Windows as your Operating System.
  • Plan Type: You can choose the Plan type based on your Subscription.

Now click on the Next: Monitoring > button to navigate to the Monitoring tab.

try azure functions c#

On the Monitoring tab, Provide the below details

  • Enable Application Insights: You can select the Yes option here.
  • Application Insights: Choose application Insights. The Region of the Application insight should be the same as the Storage account.

Then click on the Review + Create button

azure serverless functions c

Finally, click on the Create Button to create the Azure Function App.

Now if you can able to see the Azure Function App is deployed successfully with out any issue.

create azure function in azure portal

Now click on the Go to resource button to navigate to the Azure Function App that we have created. So now our Function App is ready so the next step is to create the Function. You can create that in two ways

Click on the Functions link from the left side on the Function App page and then click on the + Add button (Modern Experience)

How to create azure function in azure portal

.Or, Another way is click on the Switch to classic experience —> Continue to classic experience

create azure function from azure portal

Now click on the + Add New Function button

How to create azure function C# from azure portal

Now if we will consider the first option (Modern Experience)

Once you will click on the + Add button, Click on HTTP trigger, You can select the type of trigger based on your business need.

How to Create a function using Azure Portal

On the New Function window, You need to Provide the Function name and Authorization level as Function. But can choose the Anonymous or Admin based on your requirement. Then click on the Create Function button to create the Azure Function.

How to create Azure Functions using Azure Portal

Now you can able to see the function got created Successfully with out any issue.

function using azure portal c

Now if you want to check the Azure function is working properly or not, You can click on the Code + Test link from the left side navigation. If you want to modify or add any code then you can do that on the Editor and then run it to check if the function is working.

azure function example c#

Now, choose the HTTP method and provide the name parameter value in body in JSON format as mentioned below and then click on the Run button to execute the function.

Create your first function in the Azure portal

Now see here, the function executed successfully with the expected output and with proper response code i.e 200 OK.

One more thing, Let’s you want to check this function is working or not using the Postman app, then you can click on the Get function URL button from the top. It will provide you the function URL.

Create your first Azure function in the Azure portal

Now click on the Copy button from the below window to copy the Azure Function URL.

You will get the URL like below

https://mynewazurefunctioncsharp.azurewebsites.net/api/MyHttpTriggerFunction?code=p0/i54kge/lQInqkOdgPOPaSQBy6OZabTgcqRFyYXc/yPONlDyCplw==

Create your first Azure function using the Azure portal

Now, Open the Postman app, Select the HTTP method, paste the Azure Function URL, Provide the name parameter value in JSON format in the body and then click on the Send button. You can able to see it Provided us the expected OUtput with the Proper response code 200 OK.

Azure Function Using C#

This is how to create azure function in azure portal C# by following the above mentioned above steps.

Azure Functions Core Tools

Well, Let’s discuss the Azure functions core tools. Which is an important concept while working with the Azure Functions.

Really, Azure Functions Core Tools play a very important role while working with the Azure Functions with any of the IDE like Visual Studio or Visual Studio Code, etc. It provides us the ability to create, debug, and test the Azure Functions locally. Not only that, but it also helps us to deploy the Azure function to the Azure, Once the development and testing completed for the Azure function.

There are three versions of Azure Functions Core Tools available, Version 1.x, Version 2.x, and Version 3.x. As we know Version 3.x is the latest version of Azure Functions Core Tools.

Azure Functions Core Tools Installation

For Windows 64 bit, If you want the MSI file for the Azure Functions Core Tools Version 3.x, you can get it from the below link. You can download and install it from the below URL.

https://go.microsoft.com/fwlink/?linkid=2135274

Same way, For 32 bit, If you want the MSI file for the Azure Functions Core Tools Version 3.x, you can download and install it from the below link.

https://go.microsoft.com/fwlink/?linkid=2135275

You can also install the Azure Function Core Tools Version 3.x with the help of npm. You can use the below command to do that

npm i -g azure-functions-core-tools@3

For Mac, you can install the Azure Function Core Tools Version 3.x, you can use the below command

brew tap azure/functions
brew install azure-functions-core-tools@3

Same way for Linux, you can install the Azure Function Core Tools Version 3.x using the below command

sudo apt-get update
sudo apt-get install azure-functions-core-tools-3

Install Azure Functions Core Tools in Visual Studio 2019

You can install the Azure Functions Core Tools in Visual Studio 2019 by following the below steps.

Open the Visual Studio 2019 and then Navigate to Tools –> NuGet Package Manager –> Package Manager Console.

Azure Functions Core Tools Installation

Once the Package Manager Console opens, run the below command to install the Azure Functions Core Tools.

npm install -g azure-functions-core-tools@3
Install Azure Functions Core Tools in Visual Studio

If you are getting any error while executing the above command, you can try executing the below command

npm install -g azure-functions-core-tools@3 --force

It will install or update the Azure Functions Core Tools to the latest versions.

How to Install Azure Functions Core Tools in Visual Studio 2019

This is how you can Install Azure Functions Core Tools in Visual Studio 2019.

Install Azure Functions Core Tools in Visual Studio Code

Same way like we have installed the Azure Functions Core Tools in Visual Studio 2019, we can also install the Azure Functions Core Tools in Visual Studio Code IDE.

In the Visual Studio Code Terminal, execute the below command to install the Azure Functions Core Tools

npm install -g azure-functions-core-tools@3 --force
Install Azure Functions Core Tools in Visual Studio Code

Then it will install or it will update your Azure Functions Core Tools to the latest version

Install Azure Functions Core Tools in Visual Studio Code IDE

This is how you can Install Azure Functions Core Tools in Visual Studio Code.

You may also like following the below Articles

Conclusion

Well, in this article, we have discussed, Azure Functions .Net Core Version How To Create, then we discussed the fix to the error There Is No Functions Runtime Available That Matches The Version Specified In The Project and then we discussed Azure Functions c#, Azure Functions Core Tools and finally we discussed, Azure Functions Core Tools Installation, Install Azure Functions Core Tools in Visual Studio 2019, Install Azure Functions Core Tools in Visual Studio Code.