Azure Function - 无法为运行时启动新的语言工作线程 : dotnet-isolated

标签 azure azure-functions azure-web-app-service azure-pipelines

我有一个 dotnet 5 函数应用程序,我已经从 DevOps 管道构建和部署了几周。

在最新版本之后,我在 App Insights 中看到以下错误:

Exception type System.TimeoutException Exception message The operation has timed out. LogLevel Error prop__{OriginalFormat} Failed to start a new language worker for runtime: dotnet-isolated. Category Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher System.TimeoutException: The operation has timed out. at Microsoft.Azure.WebJobs.Script.Grpc.GrpcWorkerChannel.StartWorkerProcessAsync()

csproj 文件:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <Nullable>enable</Nullable>
    <UserSecretsId>4f786da6-0d47-4ccc-b343-638a6e34e1cf</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="local.settings.json" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="4.0.4" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.3" />
    <PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.1" />
    <PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
    <PackageReference Include="NSwag.AspNetCore" Version="13.11.1" />
    <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
    <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.MSSqlServer" Version="5.6.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\infrastructure\SmsRouter.GovNotify\SmsRouter.GovNotify.csproj" />
    <ProjectReference Include="..\SmsRouter.Infrastructure\SmsRouter.EntityFramework.csproj" />
    <ProjectReference Include="..\SmsRouter.Utrn\SmsRouter.Utrn.csproj" />
  </ItemGroup>

  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

host.json:

{
  "version": "2.0"
}

功能应用配置:

[
  {
    "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
    "value": "<my key is here>",
    "slotSetting": true
  },
  {
    "name": "AzureWebJobsStorage",
    "value": "DefaultEndpointsProtocol=https;AccountName=storesmsroutermsdn;AccountKey=<my key is here>;EndpointSuffix=core.windows.net",
    "slotSetting": false
  },
  {
    "name": "FUNCTIONS_EXTENSION_VERSION",
    "value": "~3",
    "slotSetting": false
  },
  {
    "name": "FUNCTIONS_WORKER_RUNTIME",
    "value": "dotnet-isolated",
    "slotSetting": false
  },
  {
    "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
    "value": "DefaultEndpointsProtocol=https;AccountName=storesmsroutermsdn;AccountKey=<my key is here>;EndpointSuffix=core.windows.net",
    "slotSetting": false
  },
  {
    "name": "WEBSITE_CONTENTSHARE",
    "value": "func-smsrouter-msdn-01b300",
    "slotSetting": false
  },
  {
    "name": "WEBSITE_ENABLE_SYNC_UPDATE_SITE",
    "value": "true",
    "slotSetting": false
  },
  {
    "name": "WEBSITE_RUN_FROM_PACKAGE",
    "value": "1",
    "slotSetting": false
  }
]

函数定义

[Function("HttpExample")]
    public static HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
        FunctionContext executionContext)
    {
        var response = req.CreateResponse(HttpStatusCode.OK);
        response.Headers.Add("Content-Type", "text/plain; charset=utf-8");

        response.WriteString("Welcome to Azure Functions!");

        return response;
    }

还有其他人遇到过这个问题吗?

注意:我现在已通过 Azure 门户为此创建了一个支持票证 - ID 为 2106280050000196。Github 问题 here

编辑:按照 @Kaylan 的建议,我使用 Azure CLI 使用 --runtime dotnet-isolated 参数创建一个新的函数应用程序。然后,我将我的函数部署到此(使用 devops 管道和部署 Azure 函数任务),但恐怕我仍然会看到相同的错误。

我还尝试部署到固定的应用服务计划(而不是消耗),但仍然遇到同样的问题。

最佳答案

我刚刚正在处理同样的问题。我最终通过将 .ConfigureFunctionsWorkerDefaults() 添加到我的 Program.cs 文件中修复了该问题。我不小心把它删除了。

我想我的意思是,确保您的 Program.cs 文件中有 .ConfigureFunctionsWorkerDefaults() 。这是一个例子:

using DataApi.AzureFunctions.Throttled;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureAppConfiguration(configBuilder => configBuilder.AddEnvironmentVariables())
    .ConfigureFunctionsWorkerDefaults() // <---- OMITTING THIS IS ONE POSSIBLE CAUSE OF THE ERROR "Failed to start a new language worker for runtime: dotnet-isolated."
    .ConfigureServices(Startup.Configure)
    .UseDefaultServiceProvider((_, options) =>
    {
        options.ValidateScopes = true;
        options.ValidateOnBuild = true;
    })
    .Build();

await host.RunAsync();

关于Azure Function - 无法为运行时启动新的语言工作线程 : dotnet-isolated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68086787/

相关文章:

angular - 在 Azure Web App 上部署 Angular dist/,显示默认屏幕

powershell - Azure VM 设置中的 DefaultWinRMCertificateThumbprint 字段为空

Azure AD B2C 用户导入 : Can't Associate Email w/Username

azure - 如何创建在计时器上运行的服务来查询外部 Web 服务?

python - Office365管理事件API没有内容可供下载

.net - 完整.NET Framework上的ASP.NET Core 2.1

用于计算密集型工作的 Azure FunctionApps 与 Azure 应用服务

Azure:在 blob_client 中找不到资源

Azure网络应用程序: Stack settings

azure - 我们可以在 azure 托管的 Web api 中拥有类对象的内存限制吗?