1
votes

I have an azure function app that is failing to run. I seem to have fallen into Versioning Hell with application insights.

On the Function App page it displays the error:

Microsoft.Azure.WebJobs.Extensions.ApplicationInsights: Could not load file or assembly 'Microsoft.Azure.WebJobs.Logging.ApplicationInsights, Version=3.0.27.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

This function app contains one function. I include the following packages:

    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ApplicationInsights" Version="1.0.0-preview4" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.27.0" />

I have tried removing the keys APPINSIGHTS_INSTRUMENTATIONKEY and APPLICATIONINSIGHTS_CONNECTION_STRING. Now I get a different error:

Microsoft.Azure.WebJobs.Script: The Application Insights Extension is installed but is not properly configured. Please define the "APPLICATIONINSIGHTS_CONNECTION_STRING" app setting.

What do I have to do to get my Azure Function app to start running?

I than attempted to create a whole new function app and got the following error:

Microsoft.Azure.WebJobs.Extensions.ApplicationInsights: Method not found: 'Void Microsoft.Azure.WebJobs.Logging.ApplicationInsights.ApplicationInsightsLoggerOptions.set_SamplingSettings(Microsoft.ApplicationInsights.WindowsServer.Channel.Implementation.SamplingPercentageEstimatorSettings)'.

1
I have seen very similar errors in other .net applications and not in azure functions yet. My best guess, the .NET versions of the function app and the app insights assembly have a version mismatch. You should start clean and ensure the .NET versions are matching. - Ziaullah Khan

1 Answers

1
votes

I have an unsatisfactory answer, but I'll add what I learnt for the next person who is fumbling around with this:

  • Check the runtime version of your function app. When I finally got it working, it was working on runtime version 3.2.0.0. By the time you read this, runtime version 4.* might have stabilized so these version problems have been solved, but in October 2021 it's all just too hard. See this link

enter image description here

  • If you are on runtime version 3.2.0.0, do NOT put a reference to Application Insights packages in your .csproj file (Microsoft.Azure.WebJobs.Extensions.ApplicationInsights nor Microsoft.Azure.WebJobs.Logging.ApplicationInsights)

Once I set the runtime version to ~3 and removed the application insights package, I had a working Azure function.