找不到匹配的模板:'HttpTrigger'
No templates found matching: 'HttpTrigger'
我已经从 Microsoft 安装 Azure Functions Core Tools V.3.x。
我正在尝试遵循学习路径。到目前为止,它在使用节点时运行良好。无论如何,现在我正在尝试使用 .net,所以我所做的如下:
func init
选择 dotnet 它可以在我的工作区中生成文件。
接下来。
func new
然后选择了 HttpTrigger
,然后我得到了这个错误:
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'.
因此,通过研究和阅读,我尝试遵循建议并最终使用此命令安装模板:
dotnet new -i Microsoft.Azure.WebJobs.ItemTemplates
事实上它已经确认我已经安装了 HttpTrigger
,如下图所示。但仍然存在与之前提到的相同的问题“找不到匹配的模板:'HttpTrigger'”。
我的问题,找不到模板的命令行可能出了什么问题?
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.
- 我们在本地环境中进行了研究,当我使用 azure 函数核心工具 v3 和 dotnet sdk 版本 5 系列创建 http 触发函数时它工作正常。
- 如果您使用的是 dotnet sdk 版本“6.0.100-preview.7.21379.14”,它正在通过函数核心工具预览创建函数
会失败。
- 如果使用 .net sdk 版本 5 和函数核心工具 v3 创建函数,您可以参考下面在 below blog
中共享的解决方案
Note: This solution apply for all other function features that gets the same issue with No templates found matching: etc...
.
对于那些在 HttpTrigger
或其他 azure 函数功能方面面临类似问题的人。这是问题的原因和解决方案,以及我是如何解决的:
问题原因
安装不同的 sdks 版本导致了这个问题。
如何验证
所以运行这个命令
dotnet --list-sdks
显示已安装的 dotnet 版本,在我的例子中同时安装了 dotnet 5 和 6 preview。
解决方案
所以我所做的,我用了
dotnet new globaljson
在我的 project/working 文件夹中,将版本更改为 5,它起作用了。
我已经从 Microsoft 安装 Azure Functions Core Tools V.3.x。
我正在尝试遵循学习路径。到目前为止,它在使用节点时运行良好。无论如何,现在我正在尝试使用 .net,所以我所做的如下:
func init
选择 dotnet 它可以在我的工作区中生成文件。 接下来。
func new
然后选择了 HttpTrigger
,然后我得到了这个错误:
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'.
因此,通过研究和阅读,我尝试遵循建议并最终使用此命令安装模板:
dotnet new -i Microsoft.Azure.WebJobs.ItemTemplates
事实上它已经确认我已经安装了 HttpTrigger
,如下图所示。但仍然存在与之前提到的相同的问题“找不到匹配的模板:'HttpTrigger'”。
我的问题,找不到模板的命令行可能出了什么问题?
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.
- 我们在本地环境中进行了研究,当我使用 azure 函数核心工具 v3 和 dotnet sdk 版本 5 系列创建 http 触发函数时它工作正常。
- 如果您使用的是 dotnet sdk 版本“6.0.100-preview.7.21379.14”,它正在通过函数核心工具预览创建函数 会失败。
- 如果使用 .net sdk 版本 5 和函数核心工具 v3 创建函数,您可以参考下面在 below blog 中共享的解决方案
Note: This solution apply for all other function features that gets the same issue with
No templates found matching: etc...
.
对于那些在 HttpTrigger
或其他 azure 函数功能方面面临类似问题的人。这是问题的原因和解决方案,以及我是如何解决的:
问题原因
安装不同的 sdks 版本导致了这个问题。
如何验证
所以运行这个命令
dotnet --list-sdks
显示已安装的 dotnet 版本,在我的例子中同时安装了 dotnet 5 和 6 preview。
解决方案
所以我所做的,我用了
dotnet new globaljson
在我的 project/working 文件夹中,将版本更改为 5,它起作用了。