Unable to use the methods of Find\FindAsync\FindSync in Azure Function App

I was using collection.find() method in my c# solution and it was working fine.
var doc = collection.find(filter).first()
var doc = collection.find(filter).ToList()
currently we are moving to azure cloud and I am using csx Azure function app for development. None of the extension methods for find is working while trying it in function app. Attaching the error below. I tried adding class template based on the mongodb documentation too. But no use. Please help in finding the issue in code.

Hi, @Krishnadas_Narayanapillai,

Welcome to the MongoDB Community Forums. I understand that you’re receiving an error when attempting to use First with Find, FindSync, or FindAsync in a csx Azure Function.

First<T> is defined as an extension method on both IAsyncCursor<T> and IFindFluent<T,T> in MongoDB.Driver.Core. It is unexpected that the compiler would be unable to find this extension method. To troubleshoot further, try including the code in a C# console project which includes the MongoDB .NET/C# Driver NuGet package and examine the resulting compilation errors.

If you are unsuccessful in locating the source of the problem, you can file a CSHARP bug along with a self-contained repro of the problem so that we can investigate further.


Thanks @James_Kovacs my problem was solved by using the method you provided in this reply. Thanks.

Thank you James. Issue resolved for me in a trial and error.
Error message displayed in the Azure function app is not accurate. In this case, First was returning exception when its value was null and Function app returns a non related error. It was resolved by changing the function from First() to FirstorDefault() which returns null in case of null value.

@amman_amjad, I have started to follow you because you are a SPAMMER and I want to make sure I catch your spam faster.

I flagged your other post as SPAM.