【问题标题】:Azure App Insights to APIM integration on Gov Cloud Stage & ProdAzure App Insights 与 Govcloud Stage 和 Prod 上的 API 集成
【发布时间】:2019-02-23 16:37:48
【问题描述】:

我正在将应用程序部署到 Azure Gov Cloud Stage & Prod。在 Dev & QA 中,我们使用连接到 AppInsights 的 APIM 来收集统计数据并生成警报,但是,AppInsights 在 Stage Gov Cloud 中不可用。

  1. 在 Gov Cloud on Stage 中是否有任何官方的 Application Insights 可用性时间表?

  2. 作为一种解决方法,我们计划在 Dev(例如 AI-dev)上创建一个 Application Insights 资源,该资源将与 Stage(例如 APIM-stage)中的 APIM 相关联。 但是,当我们想要进行关联时,我们会转到 Azure 门户中的 APIM 阶段并尝试选择一个 Application Insights 资源 - 没有可用的资源,Dev 和 QA 中的现有 AppInsights 资源从 Stage 中的 APIM 不可见. 是否可以配置 Stage 以使其可见?如果是,那么如何?我们正在寻找任何方法来建立这种关联 - 手动或使用 API 自动。

  3. 是否有任何其他解决方法可用于收集阶段/产品部署的应用程序/APIM 请求统计信息?最终目标是让请求警报(例如针对错误请求)适用于 Stage/Prod。

【问题讨论】:

    标签: azure azure-application-insights stage


    【解决方案1】:

    这是我们在调查后发现的:

    1. Microsoft 表示,在 Gov Cloud 中使用 Application Insights 的目标日期是 2018 年第四季度末 - 截至 2018 年 10 月 11 日。

    2./3.

    可以通过两种方式将位于 Dev(商业云)中的 Application Insights 与位于 Gov Cloud Stage 中的 APIM 相关联 - 使用 VSTS 管道任务或 REST API。事实证明,Azure Portal GUI 在这样做之后仍然不会显示任何关联或显示无效关联,但最终结果是它正在工作。

    方法 1(经过测试和工作)

    VSTS 任务:

    task: AzureResourceGroupDeployment@2
    

    VSTS 任务模板:

    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "appinsights-name": {
          "type": "string"
        },
        "instrumentation": {
          "type": "string"
        },
        "apim-name": {
          "type": "string"
        },
        "api-name": {
          "type": "string"
        }
      },
      "resources": [
        {
          "type": "Microsoft.ApiManagement/service/loggers",
          "name": "[concat(parameters('apim-name'), '/', parameters('appinsights-name'))]",
          "apiVersion": "2018-01-01",
          "scale": null,
          "properties": {
            "loggerType": "applicationInsights",
            "description": null,
            "credentials": {
              "instrumentationKey": "[parameters('instrumentation')]"
            },
            "isBuffered": true
          }
        },
        {
          "type": "Microsoft.ApiManagement/service/apis/diagnostics",
          "name": "[concat(parameters('apim-name'), '/', parameters('api-name'), '/', 'applicationinsights')]",
          "apiVersion": "2018-01-01",
          "scale": null,
          "properties": {
            "enabled": true
          }
        },
        {
          "type": "Microsoft.ApiManagement/service/apis/diagnostics/loggers",
          "name": "[concat(parameters('apim-name'), '/', parameters('api-name'), '/', 'applicationinsights', '/',parameters('appinsights-name'))]",
          "apiVersion": "2018-01-01",
          "scale": null,
          "properties": {
            "loggerType": "applicationInsights",
            "description": null,
            "credentials": {
              "instrumentationKey": "[parameters('instrumentation')]"
            },
            "isBuffered": true,
            "resourceId": "[parameters('appinsights-name')]"
          },
          "dependsOn": [
            "[resourceId('Microsoft.ApiManagement/service/apis/diagnostics', parameters('apim-name'), parameters('api-name'), 'applicationinsights')]"
          ]
        }
      ]
    }
    

    方法2(未测试)

    PUT https://management.usgovcloudapi.net/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{apimServiceName}/loggers/applicationinsights?api-version=2018-01-01 HTTP/1.1
    Authorization: Bearer
    Content-Type: application/json
    {
        "properties": {
            "loggerType": "applicationinsights",
            "description": null,
            "isBuffered": true,
            "resourceId": null,
            "credentials":{
                "instrumentationKey":"<ApplicationInsights-InstrumentationKey>"
            }
        }
    }
    
    
    PUT https://management.usgovcloudapi.net/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{apimServiceName}/diagnostics/applicationinsights?api-version=2018-01-01 HTTP/1.1
    Authorization: Bearer
    Content-Type: application/json
    
    {
        "properties": {
            "enabled": true
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-01-07
      • 1970-01-01
      • 1970-01-01
      • 2019-07-09
      • 2019-01-27
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多