在简单的F#Azure Functions项目中,即使在fsharp-azure-functions-signalr-problem.fsproj中已指定,也不会将其复制到F#Azure Functions项目(相同的local.settings.json)中的输出:
<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>
相同的C#项目没有这样的问题。
您可以执行我的F#项目的示例 git clone https://github.com/ed-ilyin/fsharp-azure-functions-signalr-problem.git
没有host.json文件,我会遇到以下错误:
> 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.).
...
因此,手动复制到已编译的文件夹可以解决此问题。我已经测试过F#,看来问题出在您的.fsproj文件中,host.json的定义应如下所示:
<Content Include="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
这对我来说很好。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句