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
installed Function1.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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.