Azure函数-未能为运行时启动新的语言工作器:点隔离

ruoxqz4g  于 2022-12-24  发布在  其他
关注(0)|答案(6)|浏览(142)

我有一个dotnet 5函数应用程序,我已经从devops管道构建和部署了几个星期。
在最新版本发布后,我在App Insights中看到以下错误:
异常类型System.TimeoutException异常消息操作已超时。LogLevel错误prop__{OriginalFormat}未能为运行时启动新的语言工作器:类别Microsoft.Azure. Web作业.脚本.工作进程.Rpc.RpcFunctionInvocationDispatcher系统.超时异常:该操作已超时。请访问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>

主机.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函数任务),但我恐怕会继续看到相同的错误。

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

pxiryf3j

pxiryf3j1#

我也在处理同样的问题。我最后把.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();
6ojccjat

6ojccjat2#

请对host.json文件进行以下更改以包含extensionBundle

{
  "version": "2.0",
    "extensionBundle": {
      "id": "Microsoft.Azure.Functions.ExtensionBundle",
      "version": "[2.*, 3.0.0)"
    }
  }
}

升级到Microsoft.Azure.Functions.Worker版本1.3.0或更高版本

Install-Package Microsoft.Azure.Functions.Worker -Version 1.3.0

确保在创建函数应用程序时指定适当的运行时。

az functionapp create --consumption-plan-location westus --name <FunctionAppName> --resource-group <ResourceGroupName> --runtime dotnet-isolated --runtime-version 5.0 --functions-version 3 --storage-account <StorageAccountName>
pxyaymoc

pxyaymoc3#

我遇到这个问题是因为我从一个“普通”的dotnet服务转移过来,需要将FUNCTIONS_WORKER_RUNTIMEdotnet调整为dotnet-isolated

本地设置json

{
  "IsEncrypted": false,
  "Values": {

    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    ....

  }
}
wnrlj8wa

wnrlj8wa4#

我刚刚运行了NuGet软件包更新:

  • Microsoft.Azure.Functions.Worker版本1.3.0 →版本1.4.0
  • Microsoft.Azure.Functions.Worker.sdk版本1.0.3 →版本1.0.4

这似乎解决了问题。

svmlkihl

svmlkihl5#

无论你执行何种操作,使用Azure应用服务和功能应用时,始终、始终、三次检查你的所有Configuration Settings是否完整且无拼写错误。缺少或拼写错误的设置可能会导致启动和依赖项注入问题,并显示类似于此的隐含消息。此外,如果你正在使用暂存槽,请确保它们的所有配置设置也正确,或使它们保持停止状态。

g2ieeal7

g2ieeal76#

当你做了一些改变,完全摧毁了应用程序之前,它甚至启动,并不知道是什么导致了这场灾难。
如果您的函数应用程序在Linux上
我不知道,祝你好运?你可以在应用启动时看到Kudu的进程日志,这可能会有所帮助。
如果您的函数应用程序在Windows上

  • 打开Kudu控制台(您的功能应用程序〉高级工具〉转到)
  • 从顶部菜单中选择“调试控制台”〉“CMD
  • 导航并打开\home\LogFiles\eventlog.xml
  • 请注意,控制台在\home处打开
  • 滚动到底部以查看最新错误

如果文件很大,你不知道哪一个是你的错误,你可以删除文件,然后重新启动功能应用程序。新的日志将被填充。

相关问题