Hello everyone,
One of the best features of Azure Application Insights is the [Live Metrics Stream]( https://docs.microsoft.com/en-us/azure/azure-monitor/app/live-stream ) which allows us to get an insight in time real data from our servers.
Some time ago the Azure team decided to implement mandatory authentication for viewing metrics in Live Stream.
Today’s post is about enabling telemetry again since the live stream is still working for most users.
(Optional) – Enable Application Insights directly in code
If you have enabled application insights directly in the azure portal and have not installed the packages in your application, you will need to install the Microsoft.ApplicationInsights.AspNetCore package and enable the service in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
}
Create an authentication key
In application insights we have the possibility to generate a KEY API so we can read the metrics and other operations. To view the logs again we will need a key that supports authentication.
In the azure portal, select the Application Insights you want to create the key for, then select the API Access menu .

Click on Create API Key at the top and name your key, the most important option for our goal is Authenticate SDK Control Channel .

Copy the generated key to a safe place, once generated the key is never shown in the Azure portal, in case of loss we will have to generate a new key.

Authenticating the QuickPulseTelemetryModule module
Now that we have our authentication key, we have to configure the QuickPulseTelemetryModule module to read our key and authenticate.

In the ConfigureServices method add the following code:
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
services.ConfigureTelemetryModule<QuickPulseTelemetryModule>((module, o) =>
{
module.AuthenticationApiKey = Configuration.GetValue("APPLICATIONINSIGHTS_APIKEY", string.Empty);
});
services.AddControllers();
}
All done! Now just republish the application and we will have our telemetry active again in the live stream.

For more information about live stream and how to customize display filters, visit the official documentation: https://docs.microsoft.com/pt-br/azure/azure-monitor/app/live-stream
This blog is part of Azure Week. Check it out for more great content!
About the Author:
Passionated about software development specially asp.net and azure
Reference
dos Santos, R (2020). Azure Application Insights – Live Metrics Stream Sample Telemetry. Available at: https://rafaeldossantos.net/azure-application-insights-live-metrics-stream-sample-temeletry/ [Accessed: 8th July 2021].