Upgrade Azure Functions to .NET Core
As of Visual Studio 2017 Preview 4, the Azure Functions tooling supports .NET Core by targeting .NET Standard. When creating a new project you can select “Azure Functions v2” to get .NET Standard support.
However, there’s currently no way to automatically migrate an existing Azure Functions project over to .NET Core. When opening an existing full framework Azure Function project, these are the available framework targets:
To upgrade to .NET Core you will have to manually edit the
.csproj files to target the correct framework and add a version
<PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> <AzureFunctionsVersion>v2</AzureFunctionsVersion> </PropertyGroup>
After reloading the project, these options will available:
Set runtime version
If you already have a deployed version of the Azure function before the upgrade, you probably have to adjust the
FUNCTIONS_EXTENSION_VERSION app settings value. Set it to
beta to be able to use the .NET Core 2.0 runtime, as described here.
.NET Standard does not support the
System.Configuration.ConfigurationManager namespace, so any use of the ConfigurationManager needs to
be switched to either
Environment.GetEnvironmentVariable or use the new configuration builder as described here.
private static readonly string SlackWebhookUrl = ConfigurationManager.AppSettings["SlackWebhookUrl"];
private static readonly string SlackWebhookUrl = Environment.GetEnvironmentVariable("SlackWebhookUrl");
Leave a Comment