在 Visual Studio 2017 年使用 Azure Functions 瞄准 .NET Core 2.0
Target .NET Core 2.0 with Azure Functions in Visual Studio 2017
自从微软几天前发布了用于 Azure Functions 的 .NET Core 2.0,我正在尝试了解如何在 VS2017 中创建一个新的面向 .NET Core 的 Functions 项目。
我已经尝试了很多配置,但最终还是选择了 .NET 4.7。
有没有人设法创建一个针对 .NET Core 的新函数?
谢谢。
目前,这是一个手动过程。您需要创建 .NET Standard 2.0 库,手动添加 function.json
并使用核心工具 运行 它。
the package Microsoft.NET.Sdk.Functions does not yet support .NET Standard 2.0 class libraries. This is the package that identifies a project as Functions project to Visual Studio and generates function.json from attributes during build.
You can still author C# class libraries that target .NET Standard 2.0, but you must use a manually-authored function.json. The templates for C# class libraries aren’t yet available in the Core Tools, but you can get a sample from GitHub.
来自 Develop Azure Functions on any platform
更新:1.0.5版本的SDK现在应该支持了,正如Fabio所说。
Microsoft.NET.Sdk.Functions 包的 1.0.5 版本支持此功能。
在您的 Azure Functions 项目中,执行以下操作:
- 将
Microsoft.NET.Sdk.Functions
软件包版本更新为 1.0.5
- 右击你的项目,点击
Edit <projectname>.csproj
选项,将TargetFramework
元素值修改为netstandard2.0
这将生成 .NET Standard 2.0 程序集,其中包含 Azure Functions 工具创建的所有项目。
截至今天,我已经能够以 "reasonably" 直观的方式将 .Net Standard 2.0 作为目标,而无需编辑任何 .csproj 文件。
您需要 Visual Studio 的较新版本。我正在使用 Visual Studio Professional 15.5.3(尽管我猜社区会起作用)。
您需要安装 Azure 开发工作负载。这将安装名为 Azure Functions and Web Jobs Tools 的扩展。
到目前为止都是普通的香草。还有 2 个额外的位对我来说一点也不直观,但最终很容易做到 - 如果你知道怎么做就很容易!
您需要确保 Azure Functions and Web Jobs Tool 是 15.0.31114.0 或更高版本 - 那是他们添加 .net core 2.0 支持的时候(参见 https://github.com/Azure/Azure-Functions/blob/master/VS-AzureTools-ReleaseNotes.md). You can update this using Tools/Extensions and Updates, or see https://marketplace.visualstudio.com/items?itemName=VisualStudioWebandAzureTools.AzureFunctionsandWebJobsTools
即使您已经这样做了,Visual Studio 让您创建面向 .net 2.0 的 Azure Functions 还是有点奇怪。当你进入 File/New Project 时,可用项目类型列表中没有任何变化,如果你 select Azure Functions,框架列表只显示 .NET Framework *,没有 .NET Standard,没有 .NET Standard。 NET 核心。
但如果此时您坚持使用 select Azure Functions,您将看到一个我以前从未见过的新对话框,它允许您 select Azure Functions v2 Preview (.NET核心).
现在,当我查看项目属性时,发现它的目标是 .NET Standard 2.0,而后者似乎包含 Microsfot.NETCore.Platforms (1.1.0)。那么这个.net core 2.0到底是不是?不太确定,但它对我的目的来说已经足够好了,所以现在要开始编写一些代码了。
干杯!
自从微软几天前发布了用于 Azure Functions 的 .NET Core 2.0,我正在尝试了解如何在 VS2017 中创建一个新的面向 .NET Core 的 Functions 项目。
我已经尝试了很多配置,但最终还是选择了 .NET 4.7。
有没有人设法创建一个针对 .NET Core 的新函数?
谢谢。
目前,这是一个手动过程。您需要创建 .NET Standard 2.0 库,手动添加 function.json
并使用核心工具 运行 它。
the package Microsoft.NET.Sdk.Functions does not yet support .NET Standard 2.0 class libraries. This is the package that identifies a project as Functions project to Visual Studio and generates function.json from attributes during build.
You can still author C# class libraries that target .NET Standard 2.0, but you must use a manually-authored function.json. The templates for C# class libraries aren’t yet available in the Core Tools, but you can get a sample from GitHub.
来自 Develop Azure Functions on any platform
更新:1.0.5版本的SDK现在应该支持了,正如Fabio所说。
Microsoft.NET.Sdk.Functions 包的 1.0.5 版本支持此功能。
在您的 Azure Functions 项目中,执行以下操作:
- 将
Microsoft.NET.Sdk.Functions
软件包版本更新为 1.0.5 - 右击你的项目,点击
Edit <projectname>.csproj
选项,将TargetFramework
元素值修改为netstandard2.0
这将生成 .NET Standard 2.0 程序集,其中包含 Azure Functions 工具创建的所有项目。
截至今天,我已经能够以 "reasonably" 直观的方式将 .Net Standard 2.0 作为目标,而无需编辑任何 .csproj 文件。
您需要 Visual Studio 的较新版本。我正在使用 Visual Studio Professional 15.5.3(尽管我猜社区会起作用)。
您需要安装 Azure 开发工作负载。这将安装名为 Azure Functions and Web Jobs Tools 的扩展。
到目前为止都是普通的香草。还有 2 个额外的位对我来说一点也不直观,但最终很容易做到 - 如果你知道怎么做就很容易!
您需要确保 Azure Functions and Web Jobs Tool 是 15.0.31114.0 或更高版本 - 那是他们添加 .net core 2.0 支持的时候(参见 https://github.com/Azure/Azure-Functions/blob/master/VS-AzureTools-ReleaseNotes.md). You can update this using Tools/Extensions and Updates, or see https://marketplace.visualstudio.com/items?itemName=VisualStudioWebandAzureTools.AzureFunctionsandWebJobsTools
即使您已经这样做了,Visual Studio 让您创建面向 .net 2.0 的 Azure Functions 还是有点奇怪。当你进入 File/New Project 时,可用项目类型列表中没有任何变化,如果你 select Azure Functions,框架列表只显示 .NET Framework *,没有 .NET Standard,没有 .NET Standard。 NET 核心。
但如果此时您坚持使用 select Azure Functions,您将看到一个我以前从未见过的新对话框,它允许您 select Azure Functions v2 Preview (.NET核心).
现在,当我查看项目属性时,发现它的目标是 .NET Standard 2.0,而后者似乎包含 Microsfot.NETCore.Platforms (1.1.0)。那么这个.net core 2.0到底是不是?不太确定,但它对我的目的来说已经足够好了,所以现在要开始编写一些代码了。
干杯!