@azbake/ingredient-app-insights

中文文档
0.1.115发布于 2024/07/25MITTypeScriptCommonJS近 30 天下载 4116

Ingredient for deploying an instance of an Application Insights resource

原始使用文档
文档目录8 节
  1. Changelogs
  2. Overview
  3. Usage
  4. Recipe for creating a resource
  5. Recipe for referencing a resource
  6. Utilities
  7. appinsights class
  8. Function Details

Changelogs

Overview

The Application Insights ingredient is a plugin for Bake. When included in a recipe, this plugin will install a instance of an Application Insights resource. A region parameter is provided to allow for a deployment to a specific region. The Smart Detection settings within the arm.json ARM template will turn off the default email notification but still leave the Smart Detection alerts enabled. Also, the naming convention for the Failure Anomalies alert is very specific and a duplicate alert may result if it is modified. Lastly, Microsoft is deprecating Smart Detection settings so this will be updated as needed once that occurs.

Usage

Recipe for creating a resource

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')]"

Recipe for referencing a resource

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')]"

Utilities

Utility classes can be used inside of the bake.yaml file for parameter and source values.

appinsights class

functiondescription
get_resource_name()Gets a full App Insights resource name.
get_instrumentation_key()Gets an App Insights instrumentation key.

Function Details

get_resource_name()

Gets an full App Insights resource name by passing a short name. Returns in the format <environment_name>ai<shortname>. For example, prodaipayroll.

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

Returns

string

get_instrumentation_key()

Gets an App Insights instrumentation key by passing a short name and resource group short name.

This is useful inside of a recipe when another ingredient needs to reference an App Insights resource deployed in a different recipe. In the example below, the instrumentation key is returned from an App Insights resource named aiproperty that's in a resource group named appinsights.

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

Returns

string

##Addendum The package.json file of this ingredient includes a dependency on "@azure/ms-rest-js": "^1.8.1". This was added so the Event Hub and Service Bus Namespace will compile. Those ingredients reference version 3.2 of their respective Azure Javascript SDK packages (@azure/arm-eventhub, @azure/arm-servicebus). An alternative is to use version 3.1 of those two packages.

版本与发布记录

@azbake/ingredient-app-insights 共发布 52 个版本,首次发布于 2019/03/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.115latest2024/07/252 年前
0.1.1142023/02/023 年前
0.1.1132022/04/054 年前
0.1.1122022/04/054 年前
0.1.1112022/04/054 年前
0.1.1102022/04/054 年前

关于 @azbake/ingredient-app-insights 的常见问题

@azbake/ingredient-app-insights 是什么?

Ingredient for deploying an instance of an Application Insights resource

如何安装 @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 和提交记录判断。