【问题标题】:Debug .NET Framework Azure Functions with v4 of runtime?使用 v4 运行时调试 .NET Framework Azure Functions?
【发布时间】:2022-11-10 19:24:03
【问题描述】:

根据 this articlethis code sample 的 v4 运行时,现在可以使用具有隔离进程模型的 .NET Framework 4.8 创建 Azure Functions 应用程序(预览版)。我已经这样做了,但我似乎无法在 Visual Studio 2022 中启动或调试它。当我尝试时,我收到以下消息:

没有与项目中指定的版本匹配的可用 Functions 运行时。

我假设函数运行时的版本在我的计算机上已经过时了,确实如此。我安装了 3.x 版本,因此我将其更新为 4.0.4736。不幸的是,Visual Studio 仍然不会启动我的项目。有没有办法让它工作?

整个 csproj 文件如下所示:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <IsPackable>false</IsPackable>
    <TargetFramework>net48</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>
</Project>

【问题讨论】:

  • 你有什么版本的视觉工作室? (主要的,次要的)。您需要 Visual Studio 17.4 的预览版才能正常工作。
  • 我在 17.3.4,所以这是有道理的。我会尝试安装它,看看会发生什么。
  • 我已经在 17.3.2 VS 2022 和 17.3.4 VS 2022 中进行了测试,但没有成功,得到了同样的错误。
  • Same issue 在 GitHub 中注册并关闭,但我找不到 VS 2022 17.4 IDE 来测试 .NET 4.8 功能解决方案,只有 VS 2022 17.4 构建工具预览包可用
  • 我已经在 github 上向 Microsoft 提出了这个问题:github.com/Azure/azure-functions-dotnet-worker/issues/1045

标签: .net azure-functions .net-4.8 azure-functions-runtime


【解决方案1】:

在带有 VS 2022 17.3.4 版本的 Azure Functions v4 .NET Framework 4.8 上,我也遇到了与以下相同的错误:

没有与项目中指定的版本匹配的可用 Functions 运行时。

我在 Azure Functions dotnet worker 的 GitHub 存储库中提出了 issue,但使用 .csproj 文件中的包引用的预览版本,它对我不起作用。

它使用以下配置代码:

.csproj

Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net48</TargetFramework>
        <AzureFunctionsVersion>v4</AzureFunctionsVersion>
        <OutputType>Exe</OutputType>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
    </ItemGroup>
    <ItemGroup>
        <Folder Include="Properties" />
    </ItemGroup>

local.settings.json

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
  }
}

HttpFunction.cs 功能代码取自同一 GitHub Repository

结果

【讨论】:

    【解决方案2】:

    我在解决这个问题时也发现了这篇文章。 @HariKrishna 上面报告和链接的问题已在 GitHub 上关闭,但它确实包含指向帮助我的解决方案的链接:

    https://github.com/Azure/azure-functions-dotnet-worker/issues/989

    VS 需要更新到至少 17.4(预览版),之后需要通过工具、选项、项目和解决方案、Azure 功能更新 Azure 功能工具,单击检查更新,然后单击下载并安装。

    【讨论】:

      猜你喜欢
      • 2020-05-11
      • 2021-02-25
      • 1970-01-01
      • 2012-06-28
      • 2019-06-12
      • 2020-02-15
      • 2022-12-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多