diff --git a/examples/ConsoleApp/ConsoleApp.csproj b/examples/ConsoleApp/ConsoleApp.csproj index f2b026e36e..53585bad83 100644 --- a/examples/ConsoleApp/ConsoleApp.csproj +++ b/examples/ConsoleApp/ConsoleApp.csproj @@ -5,6 +5,10 @@ net6.0 + + + + diff --git a/examples/ConsoleApp/Program.cs b/examples/ConsoleApp/Program.cs index 9ef70cdec2..6b7b8613f4 100644 --- a/examples/ConsoleApp/Program.cs +++ b/examples/ConsoleApp/Program.cs @@ -1,4 +1,6 @@ -using Microsoft.ApplicationInsights; +using Azure.Identity; + +using Microsoft.ApplicationInsights; using Microsoft.ApplicationInsights.Channel; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.Extensibility; @@ -26,6 +28,14 @@ static void Main(string[] args) // Add custom TelemetryInitializer services.AddSingleton(); + // Configure TelemetryConfiguration + services.Configure(config => + { + // Optionally configure AAD + //var credential = new DefaultAzureCredential(); + //config.SetAzureTokenCredential(credential); + }); + // Being a regular console app, there is no appsettings.json or configuration providers enabled by default. // Hence connection string must be specified here. services.AddApplicationInsightsTelemetryWorkerService((ApplicationInsightsServiceOptions options) => options.ConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000");