# @azbake/ingredient-app-insights 中文文档

规范地址：https://npmcn.com/package/%40azbake/ingredient-app-insights/

版本：0\.1\.115
npm 元数据更新时间：2024-07-25T14:32:53.116Z
中文译文更新时间：2026-11-07T17:02:09.917Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40azbake/ingredient-app-insights
原文对照：https://npmcn.com/package/%40azbake/ingredient-app-insights/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：55.2 kB，23 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：3 个
- peer 依赖：@azbake/core \*，@azure/ms-rest-nodeauth \*
- 首次发布：2019-03-07T23:29:29.591Z
- 最新版本发布：2024-07-25T14:32:52.943Z
- 近 30 天下载量：4116（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：52（近 12 个月 0 个）

## 中文简介

用于部署应用程序 Insights 资源实例的组件

## 安装

```sh
npm install @azbake/ingredient-app-insights
```

也可以使用：`pnpm add @azbake/ingredient-app-insights`、`yarn add @azbake/ingredient-app-insights`、`bun add @azbake/ingredient-app-insights`

## README

## 更改日志

-   [@azbake/ ingredient- app- views](https://npmcn.com/package/%40azbake/ingredient-app-insights/CHANGELOG.md)

## 概览

应用程序 Insights 成份为 Bake 的插件. 当包含在食谱中时, 此插件将安装一个应用程序 Insights 资源实例 。 提供了一个区域参数,以便部署到特定区域。 arm.json ARM模板中的智能检测设置将关闭默认的电子邮件通知,但仍会启用智能检测提醒. 此外,《公约》的命名公约 _故障异常_ 警报非常具体,如果修改,可能会产生重复警报。 最后,微软正在贬低智能检测设置,一旦发生,将视需要更新.

## 使用量

### 创建资源的路径

```yaml
name: Deploys all Application Insights resources
#shortName will be a component of the resource group name.  ie <env><shortName> --> prodappinsights
shortName: appinsights
version: 0.0.2
ingredients:
  - "@azbake/ingredient-app-insights@~0"
resourceGroup: true
recipe:
  appinsights-property:
    properties:
      type: "@azbake/ingredient-app-insights"
      source: ""
      parameters:
        #App Insights resource name
        appInsightsName: "[appinsights.get_resource_name('property')]"

  appinsights-payroll:
    properties:
      type: "@azbake/ingredient-app-insights"
      source: ""
      parameters:
        #App Insights resource name
        appInsightsName: "[appinsights.get_resource_name('payroll')]"

```

### 引用资源指南

```yaml
name: Deploys all Application Insights resources
#shortName will be a component of the resource group name.  ie <env><shortName> --> prodappinsights
shortName: propertywebappcontainer
version: 0.0.2
ingredients:
  - "@azbake/ingredient-webapp-container@~0"
  - "@azbake/ingredient-app-insights@~0"
resourceGroup: true
recipe:
  mypkg-web-site:
    properties:
      type: "@azbake/ingredient-webapp-container"
      source: "[coreutils.get_app_svc_name('ngapp')]"
      tokens:
        BASE_URL: "[coreutils.variable('svc_base_url')]"
        PROPERTY: "some value"
        APPINSIGHTS_INSTRUMENTATIONKEY: "[appinsights.get_instrumentation_key('property','appinsights')]"
      parameters:
        container_image_name: "myregistry.azurecr.io/mypkg:latest"
        container_registry_url: "[coreutils.variable('container_registry_url')]"
        container_registry_user: "[coreutils.variable('container_registry_user')]"
        container_registry_password: "[coreutils.variable('container_registry_password')]"
```

## 公用事业

工具课可以在烘焙内部使用. 参数和源值的 Yaml 文件 .

### `appinsights` 类

| 函数 | 说明 |
| --- | --- |
| 获取资源 名称 () | 获得完整的 App Insights 资源名 . |
| 获取 仪器 key () | 获得 App Insights 仪器密钥. |

### 函数细节

#### 获取资源 名称 ()

通过传递一个短名获得一个完整的 App Insights 资源名. 格式返回 `<environment_name>ai<shortname>`。例如, `prodaipayroll`。 。 。 .

```yaml
...
parameters:
  appInsightsName: "[appinsights.get_resource_name('payroll')]"
...
```

#### 回返

字符串

#### 获取 仪器 key ()

通过传递一个短名和资源组短名来获得 App Insights 仪器密钥.

当另一种成分需要参考在另一种配方中部署的 App Insights 资源时,这在配方内部是有用的. 在下面的例子中,仪器密钥是从一个名为"Aiproperty"的App Insights资源返回的,该资源属于一个名为"appinsights"的资源组.

```yaml
...
      tokens:
        APPINSIGHTS_INSTRUMENTATIONKEY: "[appinsights.get_instrumentation_key('property','appinsights')]"
...
```

#### 回返

字符串

□ 增编 此成分的 packet.json 文件包括依赖"@azure/ms-rest-js":"^1.8.1". 添加后, 事件枢纽和服务巴士命名空间将编译 。 这些成分参考版本为各自Azure Javascript SDK包的3.2 (@azure/arm-eventhub,@azure/arm-servicebus). 另一种办法是使用这两个包的第3.1版.

## 常见问题

### @azbake/ingredient-app-insights 是什么？

用于部署应用程序 Insights 资源实例的组件

### 如何安装 @azbake/ingredient-app-insights？

在项目目录运行 npm install @azbake/ingredient-app-insights，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@azbake/core（\*）、@azure/ms-rest-nodeauth（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @azbake/ingredient-app-insights 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @azbake/ingredient-app-insights 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @azbake/ingredient-app-insights 可以商用吗？

@azbake/ingredient-app-insights 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @azbake/ingredient-app-insights 的下载量有多少？

根据 npm 官方下载统计，@azbake/ingredient-app-insights 在 2026/10/08 – 2026/11/06 这 30 天内被下载 4,116 次，日均约 137 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @azbake/ingredient-app-insights 还在维护吗？

最新版本 0\.1\.115 发布于 2024/07/25（2 年前）；至今共发布 52 个版本，其中过去 12 个月发布了 0 个；首次发布于 2019/03/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

