4

Created a .NET 6.0 Isolated Function (with HTTP Trigger) in Visual Studio 2022. But when running/debug this function locally, get following error:

Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: dotnet-isolated not found. Value cannot be null. (Parameter 'provider')

Error details from console:

enter image description here

Local.settings.json:

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

host.json:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  }
}

.csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>    
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.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>
    <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
  </ItemGroup>
</Project>

Program.cs

using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .Build();

host.Run();

Project can be found in this GitHub Repo: FunctionAppTest

sulmanm
  • 41
  • 1
  • 4
  • Is [Azure Storage Emulator](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-emulator#get-the-storage-emulator) is running in your PC? - https://i.imgur.com/dYohoJi.png Just open it once and run the Azure functions again in Local! –  Apr 20 '22 at 12:17
  • Yes, Azure Storage Emulator is running – sulmanm Apr 21 '22 at 14:03

4 Answers4

4

One of the workarounds is to add program.cs in your application and adding following references in your .csproj.

<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="4.0.1" />

Make sure before you run the application try deleting the contents of your bin, Clean and Build your solution.

Try checking this similar thread.

SwethaKandikonda
  • 7,513
  • 2
  • 4
  • 18
  • There is already an Program.cs file in the project. I have added it to the question above now. Also added an GitHub Repo link – sulmanm Apr 21 '22 at 06:57
1

I had experienced the same error message:

Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: dotnet-isolated not found.

This also occurred when deployed to Azure (in a Consumption Plan, but it seemed to be a general issue on Azure hosting).

The resolution for me was to update the nuget package related to the worker process, specifically Microsoft.Azure.Functions.Worker. The project created from the Functions template originally had a reference to version 1.6.0, and this exhibited the above error; upgrading to the latest, which as of the time of posting, is version 1.8.0, resolved all issues.

Both local debugging and publishing to Azure was successful, and the Function behaved as expected.

Microsoft.Azure.Functions.Worker versions

dmcquiggin
  • 3,230
  • 24
  • 37
1

I had this issue when running locally and it was actually just caused by a change in branch, cleaning the solution solved the problem for me. I know this won't be the answer for everyone, but hopefully someone else out there scratching their head will find this useful :-).

nmase88
  • 123
  • 1
  • 4
0

I had this issue when deployed to the azure, i had to remove this package to resolve the issue.

please try removing the package - Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator

Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: dotnet-isolated not found