Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
410 stars 173 forks source link

Migrating from .NET 6 in-proc function to .NET 8 isolated produces error in Azure "Error configuring services in an external startup class." #2603

Open carsongaddgmr opened 1 month ago

carsongaddgmr commented 1 month ago

What version of .NET does your existing project use?

.NET 6

What version of .NET are you attempting to target?

.NET 8

Description

Have a .NET 6 in-proc function that was migrated to .NET 8 isolated using the migrration guide: https://learn.microsoft.com/en-us/azure/azure-functions/migrate-dotnet-to-isolated-model?tabs=net8

The function works locally and no issues were present before in Azure, but now it shows these errors despite seeming to function as expected:

Message Error configuring services in an external startup class. Details Microsoft.Azure.WebJobs.Script.ExternalStartupException : Error configuring services in an external startup class. ---> System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.AspNetCore.Routing, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. at Microsoft.Extensions.DependencyInjection.GrpcServicesExtensions.AddGrpc(IServiceCollection services) at Microsoft.Azure.WebJobs.Extensions.Rpc.WebJobsExtensionBuilderRpcExtensions.AddCoreServices(IServiceCollection services) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Extensions.Rpc\WebJobsExtensionBuilderRpcExtensions.cs : 39 at Microsoft.Azure.WebJobs.Extensions.Rpc.WebJobsExtensionBuilderRpcExtensions.MapWorkerGrpcService[T](IWebJobsExtensionBuilder builder) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Extensions.Rpc\WebJobsExtensionBuilderRpcExtensions.cs : 31 at Microsoft.Extensions.Hosting.ServiceBusHostBuilderExtensions.AddServiceBus(IWebJobsBuilder builder,Action`1 configure) at Microsoft.Extensions.Hosting.ServiceBusHostBuilderExtensions.AddServiceBus(IWebJobsBuilder builder) at Microsoft.Azure.WebJobs.ServiceBus.ServiceBusWebJobsStartup.Configure(IWebJobsBuilder builder) at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureStartup(IWebJobsStartup startup,WebJobsBuilderContext context,IWebJobsBuilder builder) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 166 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.ConfigureAndLogUserConfiguredServices(IWebJobsStartup startup,WebJobsBuilderContext context,IWebJobsBuilder builder,ILoggerFactory loggerFactory) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 130 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseWebJobsStartup(IWebJobsBuilder builder,Type startupType,WebJobsBuilderContext context,ILoggerFactory loggerFactory) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 115 at Microsoft.Azure.WebJobs.WebJobsBuilderExtensions.UseExternalStartup(IWebJobsBuilder builder,IWebJobsStartupTypeLocator startupTypeLocator,WebJobsBuilderContext context,ILoggerFactory loggerFactory) at D:\a_work\1\s\src\Microsoft.Azure.WebJobs.Host\Hosting\WebJobsBuilderExtensions.cs : 213 at Microsoft.Azure.WebJobs.Script.ScriptHostBuilderExtensions.<>c__DisplayClass7_0.b_1(HostBuilderContext context,IWebJobsBuilder webJobsBuilder) at //src/WebJobs.Script/ScriptHostBuilderExtensions.cs : 235 End of inner exception

Project configuration and dependencies

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Core" Version="1.41.0" />
    <PackageReference Include="Azure.Messaging.ServiceBus" Version="7.17.5" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.20.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.4.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
  </ItemGroup>
    <ItemGroup>
        <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
    </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Emails.Contracts\EmailTransmission.Contracts.csproj" />
    <ProjectReference Include="..\Emails\EmailTransmission.csproj" />
    <ProjectReference Include="..\IvrTransmission.Contracts\IvrTransmission.Contracts.csproj" />
    <ProjectReference Include="..\IvrTransmission\IvrTransmission.csproj" />
    <ProjectReference Include="..\QueueSender\QueueSender.csproj" />
    <ProjectReference Include="..\Sms.Contracts\SmsTransmission.Contracts.csproj" />
    <ProjectReference Include="..\Sms\SmsTransmission.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Microsoft.AspNetCore.Hosting.Abstractions">
      <HintPath>..\..\..\..\..\..\Program Files\dotnet\shared\Microsoft.AspNetCore.App\5.0.17\Microsoft.AspNetCore.Hosting.Abstractions.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
      <Content Include="settings.json">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
      <Content Update="local.settings.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
  </ItemGroup>
  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

Link to a repository that reproduces the issue

No response

kshyju commented 1 month ago

@carsongaddgmr What deployment method are you using? Does it work when deploying through another method, such as core tools?

carsongaddgmr commented 1 month ago

@kshyju It is being deployed through pipelines. I attempted to publish through the Azure CLI using core tools, but encountered an SSL connection error. I was able to publish through VS and one of the instances of the error went away, but the primary error still remains.