【Azure Function】在VS Code中创建Function项目遇见 No .NET worker runtimes found

随笔2周前发布 民商派
17 0 0

问题描述

VS Code中,已经安装了Azure Function插件,在创建C# Function时候遇见 No .NET worker runtimes found. 如下图:

【Azure Function】在VS Code中创建Function项目遇见 No .NET worker runtimes found

问题解答

最开始看见这个错误,还真的以为是自己的 Function runtime 没有安装,于是在 VS Code 的Terminal窗口执行 func -version, 和 dotnet –version, 都能得到正确返回信息。

#查看func version

func -version

#查看dotnet version

dotnet --version

【Azure Function】在VS Code中创建Function项目遇见 No .NET worker runtimes found

面对这样的情况,毫无头绪,那里的问题呢? 把VS Code关了又开,开了再关,还改为Run as Administrator模式,都没能解决!

寻求最强网络的帮助,在Google帮助中,找到了在Github的同样的问题:

Internal error: No .NET worker runtimes found when creating C# functions project #3662 : https://github.com/microsoft/vscode-azurefunctions/issues/3662

alexweininger commented on May 13, 2023

|

The error Internal error: No .NET worker runtimes found. actually has nothing to do with local installations of .NET. I can reproduce this if I configure the “Azure Functions: Project Runtime” setting to ~3 in my global VS Code settings. It works if I leave the setting as the default value (blank) or set it to ~4.

|

他提到在VS Code的设置中,如果把Function Runtime设置为 ~3, 而我们安装的Function Runtime 为 4.0,就会出现(Internal error:No .NET worker runtimes found)这样的错误。

【Azure Function】在VS Code中创建Function项目遇见 No .NET worker runtimes found

根据提示,打开Settings –> 查看Function Runtime,被设置为 ~3。根据提示,修改为 ~4 之后,问题解决。

这里被设置为~3 的原因应该是历史遗留问题,在把Function Runtime升级到v3后,没有关注到VS Code中的设置问题。

参考资料

Internal error: No .NET worker runtimes found when creating C# functions project : https://github.com/microsoft/vscode-azurefunctions/issues/3662

在 Azure 中使用 Visual Studio Code 创建 C# 函数 : https://docs.azure.cn/zh-cn/azure-functions/create-first-function-vs-code-csharp

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...