Skip to content
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

Client-side tracking with /v2/track fails with 401 Unauthorized if local authentication is disabled #2893

Open
Piedone opened this issue Aug 6, 2024 · 0 comments
Labels

Comments

@Piedone
Copy link

Piedone commented Aug 6, 2024

  • List of NuGet packages and version that you are using: Microsoft.ApplicationInsights.AspNetCore (v2.22.0), Azure.Identity (v1.12.0)
  • Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file): net8.0
  • Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.): Azure Web App, App Service on Linux, Windows via the .NET CLI locally

Describe the bug

If you disable local authentication for your AI resource, as it's recommended, then client-side tracking with /v2/track requests fail with HTTP 401 Unauthorized. This is after using SetAzureTokenCredential to configure a Service Principal, and using JavaScriptSnippet.FullScript.

image

Server-side tracking, as well as the Live Metrics control channel work (the latter is important because it shows the Service Principal working).

Enabling local authentication gets rid of this error.

I'd expect client-side tracking to work with local auth disabled too. The #2795 issue hints on this having been the case at one point.

To Reproduce

This is a minimal MVC web app, generated with the VS template:

WebApplication1.zip

You can reproduce the issue by configuring an AI connection string in the appsettings.json file, configuring a Service Principal's details in Program, and running the app.

For Immediate Support

For immediate support relating to the Application Insights .NET SDK we encourage you to file an Azure Support Request with Microsoft Azure instead of filing a GitHub Issue in this repository.
You can do so by going online to the Azure portal and submitting a support request. Access to subscription management and billing support is included with your Microsoft Azure subscription, and technical support is provided through one of the Azure Support Plans. For step-by-step guidance for the Azure portal, see How to create an Azure support request. Alternatively, you can create and manage your support tickets programmatically using the Azure Support ticket REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant