我有一个 .net 6 Web 应用程序,并部署到 azure 应用程序服务。我想为其配置应用程序见解。当您检查应用服务设置下的 Application Insights 菜单时,应用洞察已部署并启用。
我正在点击以下链接
Application Insights for ASP.NET Core applications
我被困的说明转到项目 > 添加 Application Insights 遥测。
我将 Visual Studio 与我的组织 ID 一起使用,并且部署正在客户端租户中进行。该 ID 仅用于访问客户端 Azure 门户订阅,仅用于访问客户端 Azure 门户订阅,仅用于访问客户端 Azure 门户订阅。当我转到建议的菜单选项(如上所述)时,我会弹出一个窗口,其中包含我的组织 ID 以及其下的订阅和资源。如何在不添加用于访问客户端 Azure 门户的帐户的情况下执行此步骤?
最佳答案
How do I perform this step without adding the account I use to access client azure portal?
要在不提供 Azure 帐户的情况下配置 Application Insights,您需要选择 Application Insights Sdk(本地)
。
它清楚地表明此依赖项用于跟踪和监视 WebApp 的性能,而无需连接到 Azure 中的实例。
I see service dependencies json file along with local version created in my web app project
是的,serviceDependency.json
,在我们添加本地 SDK 时添加。我们不在创建的文件中配置任何内容。
如果您使用的是最新的 .NET Core 6 或更高版本,以下代码行将添加到 Program.cs
文件中。
builder.Services.AddApplicationInsightsTelemetry();
由于您使用的是
.NET 5
,因此我没有看到添加任何代码。在
Startup.cs
文件中,在ConfigureServices
下添加以下行。
services.AddApplicationInsightsTelemetry();
- 在
appsettings.json
文件中添加与此 Link 中提到的配置相同的配置.
输出:
关于azure - 为 .net 6 Web 应用程序配置 App Insights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76523094/