Unit testing Azure Function: Cannot create an instance of TraceWriter, how to mock?

Azure Functions now can support consuming an ILogger as per this GitHub thread: https://github.com/Azure/Azure-Functions/issues/293


My suggestion would be that you use the new tooling supported in VS2017 Preview with precompiled functions to allow you to improve your function's testability. You can get started with the new tools for Azure Functions here:

https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/

Donna Malayeri has published an excellent post that explains how to use precompiled Functions with C#: https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/

This will allow you to create a Function that consumes an Interface instead of the concrete object. The answer is a bit long winded but there's a similar thread here with a nice answer:

Azure Function logging using TraceWriter in external library

ILogger