You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python函数应用中Application Insights与Monitor失效排查求助

问题:Python函数应用VNET环境下Application Insights无数据采集

已知信息:

  • 已关联Log Analytics工作区与Application Insights,函数应用配置了Application Insights的Instrument Key和连接字符串
  • 函数应用处于公开状态时Application Insights可正常工作,但VNET环境下监控模块、仪表板及故障数据均无法加载,无任何数据采集
  • Log Analytics工作区设置dailyQuotaGb: -1,无每日数据采集配额限制
  • 函数应用日志提取的ApplicationInsightsLoggerOptions配置:
ApplicationInsightsLoggerOptions { 'SamplingSettings': { 'EvaluationInterval': '00:00:15', 'InitialSamplingPercentage': 100.0, 'MaxSamplingPercentage': 100.0, 'MaxTelemetryItemsPerSecond': 20.0, 'MinSamplingPercentage': 0.1, 'MovingAverageRatio': 0.25, 'SamplingPercentageDecreaseTimeout': '00:02:00', 'SamplingPercentageIncreaseTimeout': '00:15:00' }, 'SamplingExcludedTypes': 'Request', 'SamplingIncludedTypes': null, 'SnapshotConfiguration': null, 'EnablePerformanceCountersCollection': true, 'HttpAutoCollectionOptions': { 'EnableHttpTriggerExtendedInfoCollection': true, 'EnableW3CDistributedTracing': true, 'EnableResponseHeaderInjection': true }, 'LiveMetricsInitializationDelay': '00:00:15', 'EnableLiveMetrics': true, 'EnableLiveMetricsFilters': false, 'EnableDependencyTracking': true, 'DependencyTrackingOptions': null }
  • 已尝试配置AzureMonitor服务标签的出站规则(VNET_ROUTE_ALL=1场景),问题仍未解决

可能缺失的配置项

1. 补充Application Insights特定端点的出站规则

部分旧版Python SDK不依赖AzureMonitor服务标签,需额外在NSG出站规则中允许HTTPS(443端口)流量到以下端点:

  • *.applicationinsights.azure.com
  • *.monitor.azure.com
  • dc.services.visualstudio.com

2. 配置托管标识权限

若使用连接字符串,需确保函数应用的系统托管标识对目标Application Insights资源拥有Monitoring Metrics Publisher或Contributor权限,否则无法写入遥测数据。

3. 验证SDK版本与连接字符串配置

  • 升级azure-functions和applicationinsights SDK至最新稳定版,旧版本可能存在VNET环境下的采集兼容性问题
  • 确认函数应用配置中APPLICATIONINSIGHTS_CONNECTION_STRING已正确设置(优先于Instrument Key),格式需包含InstrumentationKey和EndpointSuffix字段

4. 检查VNET路由与NSG细节

  • 确认NSG未限制443端口的出站流量,避免AI端点被误拦截
  • 若使用自定义路由表,需确保AI相关端点的流量未被路由至无法访问的网关(如NAT网关未配置对应出站规则)

5. 排查采样规则冲突

当前配置中SamplingExcludedTypes: 'Request',需确认是否存在其他隐性采样规则过滤了所有遥测。可临时将InitialSamplingPercentage保持100并重启函数,测试是否有数据产生。

内容的提问来源于stack exchange,提问作者aca1803

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 20:08:36