azure - 为 .net 6 Web 应用程序配置 App Insights

标签 azure asp.net-core-mvc .net-6.0 azure-application-insights

我有一个 .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(本地)

enter image description here

它清楚地表明此依赖项用于跟踪和监视 WebApp 的性能,而无需连接到 Azure 中的实例。

enter image description here

I see service dependencies json file along with local version created in my web app project

是的,serviceDependency.json,在我们添加本地 SDK 时添加。我们不在创建的文件中配置任何内容。

enter image description here

如果您使用的是最新的 .NET Core 6 或更高版本,以下代码行将添加到 Program.cs 文件中。

builder.Services.AddApplicationInsightsTelemetry();
  • 由于您使用的是 .NET 5,因此我没有看到添加任何代码。

  • Startup.cs 文件中,在 ConfigureServices 下添加以下行。

services.AddApplicationInsightsTelemetry();
  • appsettings.json 文件中添加与此 Link 中提到的配置相同的配置.

输出:

enter image description here

关于azure - 为 .net 6 Web 应用程序配置 App Insights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76523094/

相关文章:

c# - Dapper 一对多关系

c# - 新版本的 CsvHelper 中的 IWriterConfiguration.ReferenceHeaderPrefix 等效项

.net-6.0 - VS2022 net6.0在哪里存储ProjectGuid?

c# - 如何在 Azure Key Vault 中序列化和反序列化 PFX 证书?

azure - 如何忽略 Azure API Manager validate-jwt 策略中的特定 URL

c# - 如何区分模型绑定(bind)错误和模型验证错误?

asp.net-identity - 角色不起作用 - 错误地显示为用户不在角色中,.NET 6(从 .Net Core 3.2 升级)

azure - 从 Terraform 中的 Range 函数中排除数字列表

sql - 在 Azure VM 上从本地 SQL 切换到 Azure SQL 数据库 - 性能较低

c# - Request.Form.GetValues 在 ASP.NET Core 中不起作用