I want to easily create a F# Azure Functions (v2) Project in Visual Studio 2017.
Is there some ZIP file with a Template F# project that I can use and publish using Visual Studio Publish context menu?
I would like that VS has a F# Azure Function Project template, like it has for C#.
Azure Functions templates for F# are missing, which means lack of possibility to create F# precompiled projects in Visual Studio and Functions CLI.
There is an open github issue to introduce such support. Even though it's not apparent from this issue, I was told that templates are coming very soon.
For now, you need to:
You could use this sample as a starting point, but be sure to update to latest versions of NuGet packages.
For me, I had to go through converting a C# function project into F#:
.csproj
to .fsproj
.fsproj
file and make sure the following items are in there: <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
</ItemGroup>
<ItemGroup>
<Compile Include="Function1.fs" />
<Content Include="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
</ItemGroup>
Make sure you set host.json
and local.settings.json
to <Content...
instead of <None...
so it copies it to the output file.
Microsoft.NET.Sdk.Functions
installedFunction1.fs
file should look something like that (for an HttpTrigger
)namespace FunctionApp1
open System
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Host
open System;
open System.IO;
open System.Threading.Tasks;
open Microsoft.AspNetCore.Mvc;
open Microsoft.Azure.WebJobs;
open Microsoft.Azure.WebJobs.Extensions.Http;
open Microsoft.AspNetCore.Http;
open Microsoft.Extensions.Logging;
module Function1 =
[<FunctionName("Function1")>]
let Run ([<HttpTrigger(AuthorizationLevel.Function, [|"post"|])>] req: HttpRequest) (log: ILogger) =
async {
return "some result"
}
|> Async.StartAsTask
Publish...
Azure Function App
and follow the instructions. Make sure to select Run from pakcage file
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With