Reputation: 9
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
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"
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.
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
Upvotes: 2
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:
Make Sure you have installed these two:
Microsoft.Net.Sdk.Functions
in Project Nuget Manager in VSIf you skip 2nd option, then obviously you will not get add azure function option which I have uninstalled and tested it.
Above is the .Net Core 3.1 Project and below is the .Net Core 2.1 Project:
In Every project, this extension from the nuget package manager is to be installed.
Upvotes: 2