appinsights-instrumentation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AppInsights instrumentation

AppInsights 检测

This skill enables sending telemetry data of a webapp to Azure App Insights for better observability of the app's health.
本技能可将Web应用的遥测数据发送至Azure App Insights,从而更好地观测应用的健康状态。

When to use this skill

何时使用本技能

Use this skill when the user wants to enable telemetry for their webapp.
当用户希望为其Web应用启用遥测功能时,可使用本技能。

Prerequisites

前提条件

The app in the workspace must be one of these kinds
  • An ASP.NET Core app hosted in Azure
  • A Node.js app hosted in Azure
工作区中的应用必须属于以下类型之一:
  • 托管在Azure中的ASP.NET Core应用
  • 托管在Azure中的Node.js应用

Guidelines

操作指南

Collect context information

收集上下文信息

Find out the (programming language, application framework, hosting) tuple of the application the user is trying to add telemetry support in. This determines how the application can be instrumented. Read the source code to make an educated guess. Confirm with the user on anything you don't know. You must always ask the user where the application is hosted (e.g. on a personal computer, in an Azure App Service as code, in an Azure App Service as container, in an Azure Container App, etc.).
找出用户想要添加遥测支持的应用的(编程语言、应用框架、托管方式)组合,这将决定应用的检测方式。可通过阅读源代码做出合理推测,对于不确定的内容务必与用户确认。必须始终询问用户应用的托管位置(例如:个人电脑、Azure App Service(代码部署)、Azure App Service(容器部署)、Azure Container App等)。

Prefer auto-instrument if possible

优先使用自动检测(如果可行)

If the app is a C# ASP.NET Core app hosted in Azure App Service, use AUTO guide to help user auto-instrument the app.
如果应用是托管在Azure App Service中的C# ASP.NET Core应用,请使用AUTO 指南帮助用户完成自动检测配置。

Manually instrument

手动检测

Manually instrument the app by creating the AppInsights resource and update the app's code.
通过创建AppInsights资源并更新应用代码来手动检测应用。

Create AppInsights resource

创建AppInsights资源

Use one of the following options that fits the environment.
  • Add AppInsights to existing Bicep template. See examples/appinsights.bicep for what to add. This is the best option if there are existing Bicep template files in the workspace.
  • Use Azure CLI. See scripts/appinsights.ps1 for what Azure CLI command to execute to create the App Insights resource.
No matter which option you choose, recommend the user to create the App Insights resource in a meaningful resource group that makes managing resources easier. A good candidate will be the same resource group that contains the resources for the hosted app in Azure.
选择适合当前环境的以下选项之一:
  • 将AppInsights添加至现有的Bicep模板。可参考examples/appinsights.bicep了解需添加的内容。如果工作区中已有Bicep模板文件,这是最佳选择。
  • 使用Azure CLI。可参考scripts/appinsights.ps1了解创建App Insights资源需执行的Azure CLI命令。
无论选择哪种选项,都建议用户将App Insights资源创建在有意义的资源组中,以便于资源管理。理想的选择是与托管应用在Azure中的资源组相同。

Modify application code

修改应用代码

  • If the app is an ASP.NET Core app, see ASPNETCORE guide for how to modify the C# code.
  • If the app is a Node.js app, see NODEJS guide for how to modify the JavaScript/TypeScript code.
  • If the app is a Python app, see PYTHON guide for how to modify the Python code.
  • 如果是ASP.NET Core应用,请参考ASPNETCORE 指南了解如何修改C#代码。
  • 如果是Node.js应用,请参考NODEJS 指南了解如何修改JavaScript/TypeScript代码。
  • 如果是Python应用,请参考PYTHON 指南了解如何修改Python代码。