"Microsoft.Azure.WebJobs.Host: Error indexing method" after upgrade

Stefania Grillo 25 Reputation points
2024-02-26T16:14:37.71+00:00

Hello, I am doing the upgrade of my project from .netcore3.1 to .net7 (isolated process), azure functions from v3 to v4 and CosmoDB to v4. After changing every Microsoft.Azure.WebJobs.Extensions.* reference to the corresponding Microsoft.Azure.Functions.Worker.Extensions.*, trying to run one of my azure function I am still getting this error:
immagine

This is what I have in my .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enabled</ImplicitUsings>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Autofac" Version="8.0.0" />
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.6.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="6.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Tables" Version="1.2.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
  </ItemGroup>
  ...
</Project>

And here is how I am using the CosmosDBTrigger:

[Function("StartUploadingProcess")]        
public async Task Run(             
	[CosmosDBTrigger(             
	databaseName: "%CosmosDb_databaseId%",     
	containerName: "SalesInvoices",            
	Connection = "CosmosDb_connectionString",            
	LeaseContainerName = "SalesInvoicesLeases",            
	LeasesContainerThroughput = 500,            
	CreateLeaseContainerIfNotExists = true)]            
	IReadOnlyList<Document> input,             
	FunctionContext executionContext)
{             
	if (input != null && input.Count > 0)
    {...}
	...
}



Can someone help with this issue? Thanks a lot.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
Developer technologies | .NET | Other
{count} votes

Answer accepted by question author
  1. VenkateshDodda-MSFT 25,241 Reputation points Microsoft Employee Moderator
    2024-02-27T09:38:50.9633333+00:00

    @Stefania Grillo I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    I am summarizing the discussion and posting the same as an Answer.

    Resolution: Post upgrading the local Cosmos DB emulator and the Function app nugget package Microsoft.Azure.Functions.Worker.Extensions.CosmosDB(4.6.0) to latest versions. Customer is able to run the function successfully.

    If you have any other questions or are still running into more issues, please let me know.

    Thank you again for your time and patience throughout this issue.

    Please accept as Yes if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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