将 Application Insights 集成到开发人员门户Integrate Application Insights to developer portal

Application Insights 是 Azure Monitor 的常用功能。A popular feature of Azure Monitor is Application Insights. 它是面向开发人员和 DevOps 专家的可扩展应用程序性能管理 (APM) 服务。It's an extensible Application Performance Management (APM) service for developers and DevOps professionals. 使用它来监视开发人员门户并检测性能异常。Use it to monitor your developer portal and detect performance anomalies. Application Insights 包含功能强大的分析工具,可帮助你了解用户在访问开发人员门户时实际执行的操作。Application Insights includes powerful analytics tools to help you learn what users actually do while visiting your developer portal.

将 Application Insights 添加到门户Add Application Insights to your portal

按照以下步骤将 Application Insights 插入托管的或自承载的开发人员门户。Follow these steps to plug Application Insights into your managed or self-hosted developer portal.

重要

托管门户不需要执行步骤 1 和步骤 2。Steps 1 and 2 are not required for managed portals. 如果有托管门户,请跳到步骤 4。If you have a managed portal, skip to step 4.

  1. 为最新版本的开发人员门户设置本地环境Set up a local environment for the latest release of the developer portal.

  2. 安装 npm 包以添加用于 Azure 的 PaperbitsInstall the npm package to add Paperbits for Azure:

    npm install @paperbits/azure --save
    
  3. src 文件夹的 startup.publish.ts 文件中导入并注册 Application Insights 模块:In the startup.publish.ts file in the src folder, import and register the Application Insights module:

    import { AppInsightsPublishModule } from "@paperbits/azure";
    ...
    injector.bindModule(new AppInsightsPublishModule());
    
  4. 检索门户的配置:Retrieve the portal's configuration:

    GET /contentTypes/document/contentItems/configuration
    
    {
        "nodes": [
            {
                "site": {
                    "title": "Azure API Management - developer portal",
                    "description": "Discover APIs, learn how to use them, try them out interactively, and sign up to acquire keys.",
                    "keywords": "Azure, API Management, API, developer",
                    "faviconSourceId": null,
                    "author": "Azure API Management"
                }
            }
        ]
    }
    
  5. 使用 Application Insights 配置扩展上一步中的站点配置:Extend the site configuration from the previous step with Application Insights configuration:

    PUT /contentTypes/document/contentItems/configuration
    
    {
        "nodes": [
            {
                "site": { ... },
                "integration": {
                    "appInsights": {
                        "instrumentationKey": "xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxx"
                    }
                }
            }
        ]
    }
    

后续步骤Next steps

详细了解开发人员门户:Learn more about the developer portal: