Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why host.json not being copied to output in F# Azure Functions project?

In simple F# Azure Functions project host.json not being copied to output in F# Azure Functions project (same local.settings.json) even if specified so in fsharp-azure-functions-signalr-problem.fsproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <RootNamespace>fsharp_azure_functions_signalr_problem</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.0.2" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="negotiate.fs" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

Same C# project have no such problem.

Example of my F# project you can git clone https://github.com/ed-ilyin/fsharp-azure-functions-signalr-problem.git

Without host.json file I have following error:

> func start
...
Microsoft.Azure.WebJobs.Host: Error indexing method 'negotiate'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'connectionInfo' to type SignalRConnectionInfo. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
...
like image 378
Ed Ilyin Avatar asked Sep 14 '25 19:09

Ed Ilyin


1 Answers

So manual copy to compiled folder can solve this problem. I have test the F#, it seems problem comes from your .fsproj file, the definition of host.json should look like this:

<Content Include="host.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

This work fine on my side.

like image 104
Cindy Pau Avatar answered Sep 17 '25 09:09

Cindy Pau