1

We have some web jobs deployed in an azure web api site. We believe one of these has a memory leak, but we have not details of what is causing it. I therefore wanted to see if I could add the nuget package to application insights. https://github.com/Azure/azure-webjobs-sdk/wiki/Application-Insights-Integration

When I try and run it I just get an error as follows

enter image description here My program is just this

class Program
{
    private static string ConnectionString { get; set; }
    private static readonly JobHostConfiguration _config = new JobHostConfiguration("DefaultEndpointsProtocol=https;AccountName=mcastagstorage;AccountKey=fW/DoBsghvPgEy2/uBTZSxSSvgPoUs/jGRxV59scXmexpfDSPbSGLovjAuoLtGbSIuDBobDHyIfUdHrWWRz5DA==;EndpointSuffix=core.windows.net");

    // Please set the following connection strings in app.config for this WebJob to run:
    // AzureWebJobsDashboard and AzureWebJobsStorage
    static void Main()
    {
        string instrumentationKey = "MyKey";
        if (!string.IsNullOrEmpty(instrumentationKey))
        {
            // Wire up with default filters; Filtering will be explained later.
            _config.LoggerFactory = new LoggerFactory()
                .AddApplicationInsights(instrumentationKey, null)
                .AddConsole();

            _config.Tracing.ConsoleLevel = TraceLevel.Off;
        }

        ConnectionString = ConfigurationManager.ConnectionStrings["ConsistingEntities"].ConnectionString;

        if (_config.IsDevelopment)
        {
            _config.UseDevelopmentSettings();
        }

        var host = new JobHost(_config);
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }
}

The LoaderExceptions are as follows

enter image description here

I am very confused by the .net versions too, I am used to the original .net but now seeing .net standard and core, not sure what .net I am supposed to use for this.

Any help would be greatly appreciated

Andrew
  • 2,571
  • 2
  • 31
  • 56
  • 1
    You might want to share the value of `LoaderExceptions`, as that might shed more light. Without that, my guess is that using a bogus instrumentation key may be responsible. The keys are Guids, so ApplicationInsights may be throwing an exception when it tries to convert "MyKey". – Daniel Gimenez Jan 26 '18 at 16:14
  • Thanks I have updated the LoaderExceptions at the bottom, I updated all my nuget packages as this guy said (http://www.spdavid.com/azure-web-jobs-c-sharp/) but maybe thats not the thing to do. All seems so flakey – Andrew Jan 26 '18 at 16:23

1 Answers1

2

I tested your code and reproduced your problem.

It looks like that you are using WebJobs v3. If so, the version of Newtonsoft.Json would be 10.0.3.

It did not show that this is a bug in webjob after reading this article.

I use the following methods to solve it, if you do not mind, you could go back to the WebJobs v2 beta or update the Newtonsoft.Json to version < 10.0.3.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • Thanks that worked, I just had to try older versions of webjobs and application insights, v2 ones like you said, many thanks for the help – Andrew Jan 29 '18 at 11:40