5

I have an Azure Function v2 that calls into an utility library, which in turn instantiates a DocumentClient. When running my function locally, it throws an exception on this line:

_client = new DocumentClient(new Uri(cosmosDbEndpoint), cosmosDbAuthKey, Storage.SerializerSettings, connectionPolicy);

System.Private.CoreLib: Exception while executing function: ComponentDesignInserter-Http-UploadFiles. Microsoft.Azure.Documents.Client: Could not load type 'System.Diagnostics.Eventing.EventProviderTraceListener' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

My utility library is .NET Framework 4.7. My Azure Function v2 project is .NET Standard 2.0. Is that a problem?

Or is this symptomatic of some dependency that I need to install in the Azure Function v2 project? A dependency that the utility library has but the Azure Function v2 project doesn't?

1
  • 1
    You shouldn't have a .NET Standard project reference a .NET Framework project. Commented Mar 9, 2019 at 1:15

1 Answer 1

8

As you mention, the problem is that you are using a NET Framework 4.7 library from a NET Standard 2.0 project.

Make sure that in your NET 4.7 library, you are using the Cosmos DB Core SDK: https://www.nuget.org/packages/Microsoft.Azure.DocumentDB.Core/

Not the NET Full Framework package (https://www.nuget.org/packages/Microsoft.Azure.DocumentDB).

In your Azure Functions V2 project, you also need to use the same nuget (Core). If you are using the Microsoft.Azure.WebJobs.Extensions.CosmosDB package, it is already included.

Sign up to request clarification or add additional context in comments.

3 Comments

This worked, thanks! I had one .NET Core, and one .NET Framework application, and then i changed to Microsoft.Azure.DocumentDB.Core in the .NET Framework project and it started to work.
In my case I have other packages that depende on the full framework, for example the BulkExecutor. What could I do?
You can use Bulk Executor preview versions or use the new Bulk support in V3 SDK devblogs.microsoft.com/cosmosdb/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.