Azure Function v3 Returns error 'Did not find any initialized language workers' after change from .Net Core 3.1 to .Net 5

Gareth Frost 106 Reputation points
2021-07-12T10:15:35.143+00:00

I have an Azure Function v3 that was running using the old dotnet runtime with a .Net Core 3.1 framework version with dependant libraries, those libraries have now changed to .Net 5, so I have upgraded the function appropriately.

Having set all the required local settings and configuration elements to using the new dotnet-isolated, any execution of the HTTPTrigger function returns a 500 Error with 'The request timed out', and the console log showing the error 'Did not find any initialized language workers'.

Have currently tried all options, including creating a new Function and App Service plan, still with the same result

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
{count} vote

Accepted answer
  1. Gareth Frost 106 Reputation points
    2021-07-26T15:36:54.747+00:00

    Hello everyone and thanks for the help.

    I managed to work out the issue, after some time, and it turns out that one of the dependant libraries was getting locked up during the dependency injection setup, and hanging for the entire 5 minutes the function was live. This in turns means the the HostBuilder().Build() method never completed during the startup phase as part of the new dotnet-isolated process.

    If you get the same error I have, check that you have the startup and host.RunAsync() as part of the Program.Main() method for dotnet-isolated

    1 person found this answer helpful.

5 additional answers

Sort by: Most helpful
  1. Florian Wachs 101 Reputation points
    2021-07-26T08:37:18.43+00:00

    Same error here.
    When I deploy my .net 5 functions app (newly created) to a consumption based app service plan (newly created) it works.
    If I use my dedicated app service plan, I get this error too.

    1 person found this answer helpful.

  2. MayankBargali-MSFT 70,936 Reputation points Moderator
    2021-07-13T06:52:39.603+00:00

    @Gareth Frost Are you getting the error in locally in VS Code/Visual studio or while deploying to the azure? If it is locally then it looks like language worker could have same issue. Try installing the VS Code and function core tool again and see if it helps you. Verify if FUNCTIONS_WORKER_RUNTIME environment variable is set correctly in your local application.
    Sharing similar discussion which might help you to resolve the issue.

    0 comments No comments

  3. János László 1 Reputation point
    2021-08-30T21:29:05.553+00:00

    Hi, here's how I got it working for me:
    -in Program.cs I changed "host.Run()" to "await host.RunAsync()" and "void Main(..." to "async Task Main(..."
    -updated the following packages to the versions bellow:
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.4" OutputItemType="Analyzer" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.5.1" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />
    -VS 2019 generates a Dockerfile when right clicking the project -> Add -> Docker Support...:
    In that file I had to add:
    COPY --from=mcr.microsoft.com/dotnet/aspnet:5.0 /usr/share/dotnet /usr/share/dotnet
    after the first line.

    Here's the entire Dockerfile:

    #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
    
    FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0 AS base
    COPY --from=mcr.microsoft.com/dotnet/aspnet:5.0 /usr/share/dotnet /usr/share/dotnet
    WORKDIR /home/site/wwwroot
    EXPOSE 80
    
    FROM mcr.microsoft.com/dotnet/runtime:3.1 as runtime3_1
    FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
    # Copy .NET Core 3.1 runtime from the 3.1 image
    COPY --from=runtime3_1 /usr/share/dotnet/host /usr/share/dotnet/host
    COPY --from=runtime3_1 /usr/share/dotnet/shared /usr/share/dotnet/shared
    WORKDIR /src
    COPY ["MyFunctionApp/MyFunctionApp.csproj", "MyFunctionApp/"]
    RUN dotnet restore "MyFunctionApp/MyFunctionApp.csproj"
    COPY . .
    WORKDIR "/src/MyFunctionApp"
    RUN dotnet build "MyFunctionApp.csproj" -c Release -o /app/build
    
    FROM build AS publish
    RUN dotnet publish "MyFunctionApp.csproj" -c Release -o /app/publish
    
    FROM base AS final
    WORKDIR /home/site/wwwroot
    COPY --from=publish /app/publish .
    ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
        AzureFunctionsJobHost__Logging__Console__IsEnabled=true
    

    Hope it helps!

    0 comments No comments

  4. Siddhesh Kulkarni 1 Reputation point
    2021-09-16T08:21:04.003+00:00

    For me the issue was due to the key for the version of Node was removed somehow from the configuration section.
    WEBSITE_NODE_DEFAULT_VERSION

    132636-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.