question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SetInstrumentationKey doesn't appear to be working (Gives 'Please provide instrumentation key')

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanJosipoviccommented, Jan 16, 2022

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

0reactions
IvanJosipoviccommented, Sep 15, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found