英文:
Visual Studio detect the old Azure Functions core tools version
问题
我有一个Azure函数项目,我想使用Azure Functions Core Tools v4.x运行项目。但是Visual Studio始终选择Azure Functions Core Tools 2.6。由此,我收到以下错误消息:
您正在使用过时的Azure Functions Core Tools版本。
有关更多信息,请参见:https://aka.ms/func-v2-upgrade
我在%LocalData%/AzureFunctionTools/Releases/
中删除了所有Azure Functions Core Tools运行时。但当我再次运行项目时,安装的是Azure Function Tools 2.6版本。
如何更改以使用4.x版本?
我正在使用:
- Visual Studio 2022
- Windows 11
- .NET Core 2.2
更新:
我在互联网上找到了这篇文章。但仅向项目添加一个新函数对我来说不起作用。但当我创建一个新项目时,它选择了最新版本的Azure Function Core Tools 4.x。我仍然不知道如何在现有项目中实现这一点。
英文:
I have an Azure Function project and I want to run the project with Azure Functions Core Tools v4.x. But Visual Studio is always selecting Azure Functions Core Tools 2.6. With that, I am getting the following error:
> You are using an outdated version of the Azure Functions Core Tools.
> For more information, please see: https://aka.ms/func-v2-upgrade
I deleted all Azure Functions Core Tools runtimes in %LocalData%/AzureFunctionTools/Releases/
. But again when I run the project, Azure Function Tools 2.6 version is getting installed.
How to change this to use the 4.x version?
I am using:
- Visual Studio 2022
- Windows 11
- .NET Core 2.2
Update:
I found this article on the internet. But just adding a new function to the project did not work for me. But when I create a new project, it selects the latest version of Azure Function Core Tools 4.x . I still don't know how to do this for an existing project.
答案1
得分: 2
在我的情况下,Visual Studio 2022 尽管安装了更新版本,仍在使用较旧版本的函数运行时。这是因为它来自以下文件夹:
C:\Users<username>\AppData\Local\AzureFunctionsTools
即使删除了文件夹中的内容,它们每次都会重新生成,但仍然是旧版本。
我不得不前往Visual Studio设置,那里我找到了升级到最新版本的函数工具的方法。没有在其他任何地方通知我要升级。
英文:
In my case, visual studio 2022, was using an older version of functions runtime, despite installing newer versions.
This came from the following folder:
C:\Users<username>\AppData\Local\AzureFunctionsTools
Even upon deleting the folder contents they were regenerated everytime but only to the older version.
I had to goto visual studio settings, where I found a way to update to the latest version of the functions tool. There was no notification anywhere else asking me to upgrade.
答案2
得分: 0
I tried to reproduce the same issue in my environment with .NET Core 2.2 Azure Functions Project:
.csproj文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.38" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
你不能直接将Azure Functions v2迁移到v4,因为根据这个MS文档的规定,你不能从.NET Core 2.2迁移到6。
从.NET Core 2.2迁移到3.1 Azure Functions项目:
上述的所有操作都是在Visual Studio 2019上完成的,因为这个IDE支持Azure Functions的.NET Core 3.1版本。
从.NET Core 2.1迁移到3.1项目,然后再迁移到.NET Core 6 v4版本的Azure Function。
如果函数/应用程序代码很大,那么你需要将代码兼容到v4版本,同时还需要按照这个MS文档中指定的配置进行一些更改。
英文:
I tried to reproduce the same issue in my environment with.NET Core 2.2 Azure Functions Project:
.csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.38" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
You can't migrate the Azure Functions v2 to v4 directly as you cannot move from .NET Core 2.2 to 6 as specified in this MS Doc:
Migrated from .NET Core 2.2 to 3.1 Azure Functions Project:
Everything of the above practical done on Visual Studio 2019 because this IDE is supported up to .NET Core 3.1 Version of Azure Functions.
Migrated Azure Function from .NET Core 2.1 to 3.1 Project on Visual Studio 2022 and again migrated to .NET Core 6 v4 version.
If the Function/Application code is huge, then you need to change the code compatible to v4 version along with some changes in the configurations are specified in this MS Doc.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论