Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

97
Visualizações
Programmatically setting Application Insights instrumentation key throws error

To support Application Insights in multiple environments, we are setting the Instrumentation Key programmatically, as adviced in this post.

We have left <InstrumentationKey> in ApplicationInsights.config empty, and instead added an application setting in web.config:

<add key="ApplicationInsightsInstrumentationKey" value="1234-5678-9xxx" />

In Application_Start we do the following to set the instrumentation key:

var instrumentationKey = ConfigurationManager.AppSettings["ApplicationInsightsInstrumentationKey"];

if (string.IsNullOrWhiteSpace(instrumentationKey))
{
    throw new ConfigurationErrorsException("Missing app setting 'ApplicationInsightsInstrumentationKey' used for Application Insights");
}

TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey;

new TelemetryClient().TrackEvent("Application started");

However, this produces an exception saying "TelemetryChannel must be initialized before it can send telemetry".

Googling this exception message yields nothing, but I guess there's something additional required before events can be tracked?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Removing the <InstrumentationKey /> element from ApplicationInsights.config seems to do the trick.

I've done the exact same thing, setting the iKey in Application_Start() for a web application, and before I new() up a TelemetryClient in console applications. I do not have any element in my ApplicationInsights.config, not even a blank one. I keep a comment in that config file that says the key is being set programmatically.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda