azure - 为什么 host.json 没有被复制到 F# Azure Functions 项目中的输出?

标签 azure .net-core f# azure-functions azure-functions-core-tools

在简单的 F# Azure Functions 项目中,即使在 fsharp-azure-functions-signalr-problem.fsproj 中如此指定,host.json 也不会被复制到 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>

这对我来说效果很好。

关于azure - 为什么 host.json 没有被复制到 F# Azure Functions 项目中的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60501474/

相关文章:

arrays - 为什么遍历数组比 Seq.find 更快

azure - 没有足够的核心来在 Azure for Students 上部署资源组错误

azure - 有谁知道我们是否可以使用 TestCafe CICD 管道将屏幕截图上传到 Azure DevOps?

azure - 将 Power BI 数据源从 Excel 切换到 Azure 分析服务

asp.net-core - SignalR .net 核心过滤器

.net - 点积函数

azure - 是否可以模块化逻辑应用 ARM 模板

c# - 我们可以将访问 token 设置为不过期吗?

signalr - 包 'Microsoft.AspNet.SignalR.Core 2.2.2' 已使用 '.NETFramework,Version=v4.6.1' 恢复

f# - F# 是否有 Seq.Single : seq <'a> -> ' a?