Search code examples
c#azure-functions.net-6.0azure-functions-isolated

Isolated Azure Function throwing error on startup


I'm working on converting all of our c# Azure functions to be isolated from in-process but am running into an error that I can't find any information on. The error I am getting on startup is:

Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.RegisterDefaultConverters(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.

My Program.cs couldn't be simpler I don't think:

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

My .csproj has more extensions than I need but been throwing extensions at it to see if anything changes:

<PackageReference Include="Microsoft.Azure.AppConfiguration.Functions.Worker" Version="6.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights" Version="1.0.0-preview4" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Warmup" Version="4.0.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" />    
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />

Solution

  • Such exceptions usually denote a package version mismatch (especially when breaking changes are not handled correctly), in this particular case Microsoft.Azure.Functions.Worker is the guilty one - update it (it seems that one of the dependencies has removed the RegisterDefaultConverters extension method, also it seems that Microsoft.Azure.Functions.Worker.Sdk can be/needs to be updated also):

    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.13.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.9.0" />