SetInstrumentationKey doesn't appear to be working (Gives 'Please provide instrumentation key')
See original GitHub issueI checked out your Sample project and just replaced the cfg in index.html with an empty object.
Like so: cfg: {}
Then I went into Program.cs, removed the telemetry, and added SetInstrumentationKey
builder.Services.AddBlazorApplicationInsights(async applicationInsights =>
{
await applicationInsights.SetInstrumentationKey("MyKeyHere");
await applicationInsights.LoadAppInsights();
});
but I keep getting this warning in the browser
Failed to initialize AppInsights JS SDK for instance appInsights - Please provide instrumentation key
If I replace it directly in the index.html it works fine, but I’m trying to get the key from the appsettings since that’s what gets replaced in my deployment scripts.
I tried with both the original .NET Core version the library was written in, and also the one I’m using (5.0.4), but the problem appears in both.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Application Insights 'invalid instrumentation key' when ...
It works fine if i give it an instrumentation key from the regular azure cloud, but if i give it one from the...
Read more >Connection strings in Application Insights - Azure Monitor
Connection strings define where to send telemetry data. Key-value pairs provide an easy way for users to define a prefix suffix combination for ......
Read more >Monitoring Applications using Application Insights
Exercise 1: Creating Instrumentation Key. Go to Azure Portal from here. Click on + New icon to create a new Application Insights.
Read more >Dynamically using Instrumentation Keys with Azure ...
Set the app insights instrumentation key if we have one in our Azure app service. string instrumentationKey = ConfigurationManager.
Read more >Instrument for Telemetry with Application Insights
The value for InstrumentationKey can be copied from the Azure portal. Navigate to Application Insights and then to the resource (PRM-DAT in the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have updated the readme with a new approach on how to set the instrumentation key. See, https://github.com/IvanJosipovic/BlazorApplicationInsights#set-instrumentation-key-programmatically
I have documented a new approach for Blazor WASM ASP.NET Hosted Projects in the Readme. This solution will need to be manually implemented for self hosted Blazor, it essentially uses a cookie to store the ConnectionString.
I do not recommend using SetInstrumentationKey and SetConnectionString (due to https://github.com/IvanJosipovic/BlazorApplicationInsights/issues/90) and they will likely be marked as obsolete in a future version.