chetan bhat
chetan bhat

Reputation: 9

Missing Azure functions template under Add new item in Visual Studio

I'm trying to use Visual studio 2019 to create develop & test Azure function locally. So I did install the ASP.NET & Azure development workload modules from the Visual Studio installer. I was able to create a new project using the azure function template using .NET 2. This created a boilerplate .cs code.

Now here's where the problem is. I'm trying to add a new azure function to my project using the Add > New Item menu from the context menu when right clicked on the project. In the list of templates there is no Azure function templates listed. I've used the search option to filter the templated but end up getting No items found message.

I am not sure what's wrong with my Visual Studio. Does anyone have faced this issue with missing templates and resolved it? Let me know.

Upvotes: 0

Views: 2663

Answers (2)

Grace A
Grace A

Reputation: 175

Adding to @HariKrishnaRajoli-MT 's answer that was very helpful to me, I did have to do a little more digging to get the nuget packages in.

A missing microsoft.net.sdk.functions is the reason why we are not seeing the New Azure Functions in the Add Context Menu.

My issue was caused by only having my package source as Microsoft Visual Studio Offline Packages, which gave the message -

microsoft.net.sdk.functions not available in this source

I needed to add a Package Source that had the microsoft.net.sdk.functions available. In order to do that, in your Solution Explorer, Right-Click on Dependencies and click on "Manage NuGet Packages"

enter image description here

Click on the cogwheel to get the below. Click the + sign to add a source and enter the values as seen below in Name and Source.

Name: nuget.org

Source: https://api.nuget.org/v3/index.json

Click Update and then close.

enter image description here

Go back to the window in the first image, select the "nuget.org" and wait until update runs. You should be able to see Your Azure function icon next to the app and the New Azure Function in the context menu.

Ref:

https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file

https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio#package-sources

Upvotes: 2

anon
anon

Reputation:

I tried to reproduce your issue as I have added another azure function class to the function app project successfully in visual studio 2019 locally. Steps I followed:

  1. Visual Studio 2019 > Opened existing Azure Function App Project > Right Clicked on the Project and Select Add > Add New Azure Function

enter image description here

  1. After clicking on Add New Function > Select Azure Function from the plenty of class templates names provided in the box.

enter image description here

  1. It will ask you which trigger template required for your azure function class. Based on requirement, select the trigger template.

enter image description here

  1. After Selecting the trigger template, click on Add and then you will see the following azure function class in your project.

enter image description here


Make Sure you have installed these two:

  1. Azure Development Pack in Visual Studio Installer

enter image description here

  1. Microsoft.Net.Sdk.Functions in Project Nuget Manager in VS

If you skip 2nd option, then obviously you will not get add azure function option which I have uninstalled and tested it.

enter image description here

Above is the .Net Core 3.1 Project and below is the .Net Core 2.1 Project:

enter image description here

In Every project, this extension from the nuget package manager is to be installed.

Upvotes: 2

Related Questions