Answered by:
Microsoft.ApplicationInsights Error: InstrumentationKey cannot be empty

Question
-
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use
_telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null);
I am getting an error saying: InstrumentationKey cannot be empty.
I have already gone through the URL but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro).
I have also tried updating the config file with the instrumentation key
<ComponentID>{Instrumentation Key}</ComponentID>
But, that didn't work too.
Thanks.
- Moved by Daniele Muscetta Thursday, November 27, 2014 6:52 PM AI question, not OpInsights
Thursday, November 27, 2014 12:26 AM
Answers
-
When you install AI via nuget InstrumentationKey is not populated automatically.
You have 2 options:
In ApplicationInsights.config add: <InstrumentationKey>{Your Key}</InstrumentationKey>
or
Set it in runtime. It is described here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/9284e1bd-d280-4213-8558-16acb20eabb4/new-azure-portal-application-insights-azure-cloud-service-deployment?forum=ApplicationInsights#170cff84-7914-46fd-bb1c-a1f5a51b20c7
Anastasia
- Proposed as answer by Dmitry G MatveevMicrosoft employee Monday, February 9, 2015 11:45 PM
- Marked as answer by Dmitry G MatveevMicrosoft employee Monday, March 16, 2015 5:43 PM
Thursday, December 4, 2014 7:23 AM -
Hello Skenflow,
ComponentID tag was the part of the old applicationInsights.config schema which is not compatible with the latest releases of AI SDK. My guess is that VS 2013 Update 3 would've updated this file but VS 2012 just cannot/doesn't know how.
To fix the issue you would need:
- Acquire new version of Application Insights Config file (Application Insights Status Monitor from WEB PI feed can install it for the application in Runtime, the latest Application Insights Web nuget will do it for the project in VS, ...)
- Make sure you have the <InstrumenationKey> set in this file as per Anastasia's post;
- Double check that the Instrumentation Key in Application Insights config in /bin (if such file exists, depends on the project type you use and debug settings) matches the one in the root of your application (I came across such problem before where SDK says "Empty Key" because it's empty in bin but not empty in root).
Dmitry Matveev
- Proposed as answer by Dmitry G MatveevMicrosoft employee Monday, February 9, 2015 11:45 PM
- Marked as answer by Dmitry G MatveevMicrosoft employee Monday, March 16, 2015 5:43 PM
Saturday, December 6, 2014 12:35 AM
All replies
-
When you install AI via nuget InstrumentationKey is not populated automatically.
You have 2 options:
In ApplicationInsights.config add: <InstrumentationKey>{Your Key}</InstrumentationKey>
or
Set it in runtime. It is described here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/9284e1bd-d280-4213-8558-16acb20eabb4/new-azure-portal-application-insights-azure-cloud-service-deployment?forum=ApplicationInsights#170cff84-7914-46fd-bb1c-a1f5a51b20c7
Anastasia
- Proposed as answer by Dmitry G MatveevMicrosoft employee Monday, February 9, 2015 11:45 PM
- Marked as answer by Dmitry G MatveevMicrosoft employee Monday, March 16, 2015 5:43 PM
Thursday, December 4, 2014 7:23 AM -
Hello Skenflow,
ComponentID tag was the part of the old applicationInsights.config schema which is not compatible with the latest releases of AI SDK. My guess is that VS 2013 Update 3 would've updated this file but VS 2012 just cannot/doesn't know how.
To fix the issue you would need:
- Acquire new version of Application Insights Config file (Application Insights Status Monitor from WEB PI feed can install it for the application in Runtime, the latest Application Insights Web nuget will do it for the project in VS, ...)
- Make sure you have the <InstrumenationKey> set in this file as per Anastasia's post;
- Double check that the Instrumentation Key in Application Insights config in /bin (if such file exists, depends on the project type you use and debug settings) matches the one in the root of your application (I came across such problem before where SDK says "Empty Key" because it's empty in bin but not empty in root).
Dmitry Matveev
- Proposed as answer by Dmitry G MatveevMicrosoft employee Monday, February 9, 2015 11:45 PM
- Marked as answer by Dmitry G MatveevMicrosoft employee Monday, March 16, 2015 5:43 PM
Saturday, December 6, 2014 12:35 AM