No templates found matching: 'HttpTrigger'

Viewed 1825

I have install Azure Functions Core Tools V.3.x from Microsoft.

I am trying to follow a learning path. So far it worked fine when working with nodes. Any way, now I am trying to experiment with .net, so what I did is following:

func init

Chose dotnet it generate files in my workspace fine. Next.

func new

And chose HttpTrigger, than I get this error:

No templates found matching: 'HttpTrigger'.
To list installed templates, run 'dotnet new --list'.
To search for the templates on NuGet.org, run 'dotnet new HttpTrigger --search'.

So by researching and reading, I tried to follow a suggestion and ended up with this command to install the templates:

dotnet new -i Microsoft.Azure.WebJobs.ItemTemplates

And indeed it has confirmed that I have HttpTrigger installed as you can see in the image below. But still has the same issue as mentioned before "No templates found matching: 'HttpTrigger'."

My Question, what is possibility going wrong with in command line that the template is not found?

Note:

  • I have used cmd and powershell with administrator privilege as well.
  • When I try to create a project in Visual Studio 2019 it can create HttpTriggers without issues.
  • I have both Visual Studio 2019 and 2022 installed on Windows 10 environment.
  • This is first time I use Azure Functions Core Tools and learning it.

enter image description here

3 Answers

Note: This solution apply for all other function features that gets the same issue with No templates found matching: etc....

For those that face similar issue with HttpTrigger or other azure function features. Here is the cause and the solution to the issue and how did I solved it:

Cause of the problem

having different sdks versions install created the issue.

How to validate

So running this command

dotnet --list-sdks

shows that the installed dotnet version, in my case both dotnet 5 and 6 preview was installed.

Solution

so what I did, I used

dotnet new globaljson

in my project/working folder and then updated the version in global.json to 5, and it worked .

  • We have researched in our local environment while it is working fine when i am creating the http trigger function using azure function core tools v3 & dotnet sdk version 5 family.
  • If you are using dotnet sdk version "6.0.100-preview.7.21379.14" which is in preview creation of functions through function core tools will fail.
  • If creation of function with .net sdk version 5 & function core tool v3 you can refer below solution shared in the below blog

Microsoft documentation alerts that you shouldn't use two different package managers to install Azure Functions Core Tools. Either this is the issue (it was mine at least), or you have made Azure Functions Core Tools confused somehow or have several versions. In my case: I checked for global packages installed with npm:

npm list -g --depth 0

Confirmed that I had a Azure Functions Core Tools outdated global package v3.

Removed it with:

npm uninstall -g azure-functions-core-tools

Reinstalled it using the MSI installer you can find here

All good after this. Because its the Core Tools v4, I can now use .Net6 with it, all templates included.

Related