How to Setup Application Insights in an Azure WebJob

I just spent way too much time getting AppInsights working in an Azure WebJob.

Here are a couple of tips:

1. Make sure you are using the right InstrumentationKey. Go here to find out how:

2. Make sure you programmatically set your InstrumentationKey (Also store it in Azure app settings in case you need to change it.

3. Make sure you call Flush after you write any events

4. Install the following Nuget packages

5. Make sure you do not have an <InstrumentationKey> element in your ApplicationInsights.config file