Skip to content

Migrate analytics to explicit managed identity#456

Merged
JoeProgrammer88 merged 2 commits intomainfrom
MigrateAnalyticsToExplicitManagedIdentity
Jan 13, 2026
Merged

Migrate analytics to explicit managed identity#456
JoeProgrammer88 merged 2 commits intomainfrom
MigrateAnalyticsToExplicitManagedIdentity

Conversation

@JoeProgrammer88
Copy link
Copy Markdown
Member

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 AnalyticsService to improve environment handling and simplify Azure configuration checks. The most important changes include switching to ManagedIdentityCredential for authentication, using conditional compilation to separate development and production logic, and removing unnecessary workspace ID checks throughout the service.

Environment-specific initialization:

  • The Azure Application Insights client (_logsQueryClient) is now initialized using ManagedIdentityCredential instead of DefaultAzureCredential, and only in non-DEBUG builds. In DEBUG builds, local hardcoded data is used for development. [1] [2]

Simplification of Azure configuration checks:

  • Removed redundant checks for workspace ID when determining if Azure analytics should be used; now only checks for _isAzureConfigured and _logsQueryClient throughout the service methods (GetAnalyticsDataAsync, GetPageViewsAsync, GetPdfDownloadsAsync, GetSearchTermsAsync). [1] [2] [3] [4]

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.
@JoeProgrammer88 JoeProgrammer88 merged commit 3259058 into main Jan 13, 2026
1 check passed
@JoeProgrammer88 JoeProgrammer88 deleted the MigrateAnalyticsToExplicitManagedIdentity branch January 13, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant