-
Notifications
You must be signed in to change notification settings - Fork 293
Add Entra ID (Azure Active Directory) authentication support #3054
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for Entra ID (formerly Azure Active Directory) authentication to Application Insights .NET SDK using Azure.Core.TokenCredential. This enables authentication using managed identities, service principals, and other Azure credential types instead of relying solely on instrumentation key-based authentication.
Key Changes:
- Added public API
SetAzureTokenCredential(TokenCredential)method toTelemetryConfigurationfor non-DI scenarios - Added
Credentialproperty toApplicationInsightsServiceOptionsin AspNetCore and WorkerService packages - Implemented credential flow from service options to Azure Monitor Exporter in both packages
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| BASE/src/Microsoft.ApplicationInsights/Extensibility/TelemetryConfiguration.cs | Added public SetAzureTokenCredential method to configure credentials in non-DI scenarios, using ConfigureOpenTelemetryBuilder to flow credentials to Azure Monitor Exporter |
| NETCORE/src/Shared/Extensions/ApplicationInsightsServiceOptions.cs | Added Credential property and updated CopyPropertiesTo to include credential copying |
| NETCORE/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/ApplicationInsightsExtensions.cs | Added credential flow logic to copy credentials from service options to Azure Monitor Exporter options |
| NETCORE/src/Microsoft.ApplicationInsights.WorkerService/ApplicationInsightsExtensions.cs | Added credential flow logic to copy credentials from service options to Azure Monitor Exporter options |
| BASE/Test/Microsoft.ApplicationInsights.Test/Microsoft.ApplicationInsights.Tests/TelemetryConfigurationAadTests.cs | Added comprehensive unit tests for SetAzureTokenCredential method including validation and lifecycle tests |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsServiceOptionsTests.cs | Added tests for Credential property getter/setter and CopyPropertiesTo method |
| NETCORE/test/Microsoft.ApplicationInsights.AspNetCore.Tests/Extensions/ApplicationInsightsAadIntegrationTests.cs | Added integration tests verifying credential flow from service options to exporter in AspNetCore |
| NETCORE/test/Microsoft.ApplicationInsights.WorkerService.Tests/WorkerServiceAadIntegrationTests.cs | Added integration tests verifying credential flow from service options to exporter in WorkerService |
| WEB/Src/Web/README.md | Added documentation section explaining AAD authentication configuration with code example |
| LOGGING/README.md | Added documentation section explaining AAD authentication with NLog including code example |
| examples/ClassicAspNetWebApp/Global.asax.cs | Added commented example showing how to configure AAD authentication in classic ASP.NET |
| examples/NLogConsoleApp/Program.cs | Added commented example showing how to configure AAD authentication with NLog |
| CHANGELOG.md | Added entry documenting the new Entra ID authentication support feature |
| .publicApi/*.txt | Updated public API surface files to reflect new public members across affected packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR adds support for Entra ID (formerly Azure Active Directory) authentication to Application Insights .NET SDK using
Azure.Core.TokenCredential. This enables authentication using managed identities, service principals, and other Azure credential types instead of relying solely on instrumentation key-based authentication.Changes
Public API Additions
SetAzureTokenCredential(TokenCredential)public method toTelemetryConfigurationCredentialproperty toApplicationInsightsServiceOptionsCredentialproperty toApplicationInsightsServiceOptionsImplementation
ApplicationInsightsServiceOptions.CredentialtoAzureMonitorExporterOptions.Credentialin both AspNetCore and WorkerService packagesTelemetryConfiguration.SetAzureTokenCredential()method configures credential for non-DI scenarios (WEB, NLog)using Azure.Monitor.OpenTelemetry.Exporterto TelemetryConfiguration.csDocumentation
WEB/Src/Web/README.mdwithGlobal.asax.csexampleLOGGING/README.mdfor NLog usersexamples/ClassicAspNetWebApp/Global.asax.csexamples/NLogConsoleApp/Program.csTests
SetAzureTokenCredentialmethod validation and lifecycleCredentialproperty andCopyPropertiesTomethodPublicAPI Updates
PublicAPI.Unshipped.txtfiles for Microsoft.ApplicationInsights, Microsoft.ApplicationInsights.AspNetCore, and Microsoft.ApplicationInsights.WorkerServiceUsage Examples
AspNetCore / WorkerService (DI-based)
Classic ASP.NET (WEB)
NLog