当 运行 azure web 应用程序时,我是否需要向应用程序添加应用程序洞察遥测

Do I need to add application insights telemetry to application when running azure web apps

我最近将我的代码移到了 Azure,并且 运行 它在 Azure Web 应用程序服务中。我还有一个应用程序洞察资源,它向我展示了来自特定网络应用程序的数据。现在我想知道我是否还需要将 services.AddApplicationInsightsTelemetry("instrumentationKey"); 添加到我的 C# .net 6.0 项目的启动中。包括所有偏离路线的包裹。

添加遥测是否可以让我了解应用程序洞察的更多细节?当 运行 一个 Azure Web 应用程序时,我什至需要在我的项目中指定一些应用程序洞察力还是它为你管理?找不到真正的答案。

如果您需要添加它,当您有两个生产环境作为备份情况时,您将如何管理检测密钥?您可能希望两个 Web 应用程序都将数据发送到正确的应用程序洞察资源。

Does adding the telemetry give me more detail in application insights? Do I even need to specify something of application insights in my project when running a Azure Web App or is it managing that for you? Couldn't really find an answer to this.

不一定。使用代理记录所有主要遥测数据,请参阅 the docs. However, there are certain advantages of using the SDK. Mainly, the ability to add additional data to your telemetry or reduce telemetry by using TelemetryInitializer and TelemetryProcessor as described here

此外,您可以将 ILogger 输出连接到 Application Insights,并且您可以手动 track custom telemetry using the SDK

If you need to add it, how would you manage instrumentation keys when you have two Production environments as a backup situation? You would want both web apps to send data to the correct app insights resource.

与任何其他连接字符串或秘密一样,如数据库连接字符串。概述了一些选项 here。我们通常为每个环境使用单独的 appsettings.json,但您也可以从 Azure Key Vault 或应用程序配置服务或任何您喜欢的方式获取检测密钥。