Skip to content

Move to 'Azure.Identity' v1.14.2 and refactor the telemetry library #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Azure.Identity" Version="1.14.2" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="2.0.0" />
<PackageReference Include="System.Management.Automation" Version="7.4.7">
Expand Down
24 changes: 7 additions & 17 deletions shell/agents/Microsoft.Azure.Agent/Telemetry.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Text.Json;

using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.WorkerService;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.ApplicationInsights.Extensibility;

namespace Microsoft.Azure.Agent;

Expand Down Expand Up @@ -198,21 +197,12 @@ internal class Telemetry

private Telemetry()
{
// Being a regular console app, there is no appsettings.json or configuration providers enabled by default.
// Hence connection string must be specified here.
IServiceCollection services = new ServiceCollection()
.AddApplicationInsightsTelemetryWorkerService((ApplicationInsightsServiceOptions options) =>
{
// Application insights in the AME environment.
options.ConnectionString = "InstrumentationKey=7a75c4d0-ae0b-4a63-9fb3-b99271f79537";
options.EnableHeartbeat = false;
options.EnableDiagnosticsTelemetryModule = false;
});

// Obtain TelemetryClient instance from DI, for additional manual tracking or to flush.
_telemetryClient = services
.BuildServiceProvider()
.GetRequiredService<TelemetryClient>();
var config = TelemetryConfiguration.CreateDefault();
// Application insights in the AME environment.
config.ConnectionString = "InstrumentationKey=7a75c4d0-ae0b-4a63-9fb3-b99271f79537";

// Create TelemetryClient with the configuration
_telemetryClient = new TelemetryClient(config);

// Suppress the PII recorded by default to reduce risk.
_telemetryClient.Context.Cloud.RoleInstance = "Not Available";
Expand Down
Loading