Debugging The Azure Function With .NET Framework V1

Introduction to Azure Function

 
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it.
 
Azure Functions lets you develop serverless applications on Microsoft Azure.
 
Prerequisites
  • Azure Subscription 
  • Visual Studio 2017 
Background of the issue 
 
If you want to create Azure Function with .net Framework i.e. Azure Function v1, Visual studio lets you create the function.

Even if you publish it, it will work smoothly. However, if you want to debug the Azure Function on your local,  unlike the initial old days using Azure CLI, you will get the below error in the Azure CLI window.

A ScriptHost error has occurred,

[2/26/2019 10:48:26 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type TraceWriter. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

[2/26/2019 10:48:26 AM] Error indexing method 'Function1.Run',

Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type TraceWriter. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

Screenshot
 

Solution 

After trying various options and alternatives we came to the root cause.

The Reason behind the error is, the latest Microsoft.Net.SDK.Functions after “1.0.11” has lots of bugs for Azure function v1 upon which Microsoft is barely working as they are recommending the hardcore .net framework developer to use Azure Function v2 (.net Core). However, it works smoothly with version V2.

The workaround

To overcome the issue, rather than starting with the .NET Core, we downgraded the version.
  • Expand/Open Solution Explorer
  • Right click on Solution
  • Click on Manage NuGet Packages for solutions (Alternatively, you can also you package manager in case if you are good at it)
  • Under the installed section in NuGet Window, select “Microsoft.NET.Sdk.Functions” package
  • In the right side, select the version from Versions Dropdown “10.0.11”
  • Click on “Update” button
  • Check the Preview Changes Dialog and click on “OK”
  • Accept the License and Agreement
  • Wait for a while until the packages get updated. Check that the installed Version is set to “10.0.11”

Once you Hit the F5 or use start debugging Menu from the Menu Ribbon:

 
To cross check, you can copy the local URL of the function and paste in the browser

http://localhost:7071/api/Function1

http://localhost:7071/api/Function1?name=UmeshMurumkar,