Migrate analytics to explicit managed identity#456
Merged
JoeProgrammer88 merged 2 commits intomainfrom Jan 13, 2026
Merged
Conversation
Switched authentication in AnalyticsService from DefaultAzureCredential to ManagedIdentityCredential, ensuring the Azure LogsQueryClient uses managed identity for authentication instead of multiple possible credential sources.
Wrap Azure client initialization in conditional compilation to use local data in DEBUG builds. Remove workspace ID checks, relying on client presence for Azure configuration. Improve error handling and simplify environment-specific logic for analytics data retrieval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simplifying the Application Insights log query code and using ManagedIdentity explicitly instead of relying on AzureDefaultCredential to select the ManagedIdentity in the production environment.
Copilot Summary
This pull request updates the initialization and usage of the Azure Application Insights client in the
AnalyticsServiceto improve environment handling and simplify Azure configuration checks. The most important changes include switching toManagedIdentityCredentialfor authentication, using conditional compilation to separate development and production logic, and removing unnecessary workspace ID checks throughout the service.Environment-specific initialization:
_logsQueryClient) is now initialized usingManagedIdentityCredentialinstead ofDefaultAzureCredential, and only in non-DEBUG builds. In DEBUG builds, local hardcoded data is used for development. [1] [2]Simplification of Azure configuration checks:
_isAzureConfiguredand_logsQueryClientthroughout the service methods (GetAnalyticsDataAsync,GetPageViewsAsync,GetPdfDownloadsAsync,GetSearchTermsAsync). [1] [2] [3] [4]