【Azure 应用程序见解】通过Azure Funciton的门户启用Application Insights后,Application Insights无法收到监控数据

问题描述

比较早期创建的Azure Funciton服务,近期发现在门户中已经启用了Application Insights功能,但是正确配置Applicaiton Insights后,却无法获取关联的Azure Function的监控数据?

问题分析

到目前为止,Azure Function已经经历了三个版本的发展,可以通过 FUNCTIONS_EXTENSION_VERSION 查看当前Azure Funciton的版本:

从官方的文档中,发现Application Insights已经在 Function V1.x, V2.x及V3.x的版本支持了。但是经过实测,V2.x, V3.x都能成功发送监控数据到Application Insights中而最早的V1.x版本却无法发送监控数据这与本文问题匹配。

最后经过咨询确认, 在中国区Function V1.X的集成除了要在门户中配置Applcation Insights外,还需要再Funciton的host.json中的applicationInsights一节修改endpoint并指向中国区的终结点:

Function host.json示例内容:

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[1.*, 2.0.0)"
  },
  "applicationInsights": {
    "ingestionEndpoint": "https://dc.applicationinsights.azure.cn/v2/track",
    "liveEndpoint": "https://live.applicationinsights.azure.cn/QuickPulseService.svc"
  }
}

问题解决

1) Azure Function 页面中启用Application Insights

2) 修改Funciton的host.json文件,添加applicationInsights,ingestionEndpoint和liveEndpoint

参考资料

如何为 Azure Functions 配置监视: https://docs.azure.cn/zh-cn/azure-functions/configure-monitoring?tabs=v1

Azure Functions 运行时版本概述: https://docs.azure.cn/zh-cn/azure-functions/functions-versions

Application Insights Regions that require endpoint modification: https://docs.microsoft.com/en-us/azure/azure-monitor/app/custom-endpoints?tabs=net#regions-that-require-endpoint-modification

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

原文地址:https://www.cnblogs.com/lulight/p/14713810.html