Azure functions 无法查看应用程序服务功能的调用日志

Azure functions 无法查看应用程序服务功能的调用日志,azure-functions,Azure Functions,当我将功能代码(运行时版本:3.0.14287.0(~3))发布到应用程序服务时,所有内容似乎都在运行,但我在门户中任何功能的监视器页面中都看不到任何调用日志-它始终为空。我有计时器触发的功能,应该会显示出来 我正在使用ARM脚本部署包含应用程序服务的资源组。该部署由以下资源组成: Microsoft.Insights/components Microsoft.KeyVault/vaults Microsoft.Storage/storageAccounts Microsoft.Web/serv

当我将功能代码(运行时版本:3.0.14287.0(~3))发布到应用程序服务时,所有内容似乎都在运行,但我在门户中任何功能的监视器页面中都看不到任何调用日志-它始终为空。我有计时器触发的功能,应该会显示出来

我正在使用ARM脚本部署包含应用程序服务的资源组。该部署由以下资源组成:

Microsoft.Insights/components
Microsoft.KeyVault/vaults
Microsoft.Storage/storageAccounts
Microsoft.Web/serverfarms
Microsoft.Web/sites
我可以使用如下查询在Application Insights中查看函数跟踪:

traces 
| order by timestamp desc
| where message contains 'telemetry'
我不知道它是否相关,但在应用程序服务概述页面中,我确实看到以下警告:

Storage is not configured properly, Function scaling will be limited. Click to learn more.
我正在使用以下应用程序服务appsettings将其连接到App Insights:

APPINSIGHT_INSTRUMENTATIONKEY: <instrumentation key from app insights>
AzureWebJobsDashboard: <storage acct connect string>
AzureWebJobsStorage: <storage acct  connect string>
FUNCTIONS_EXTENSION_VERSION ~3
FUNCTIONS_WORKER_RUNTIME dotnet
{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Information",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace"
    }
  }
}

在文件
host.json
中,对于字段“Function”,将其值设置为Trace。然后可以将其登录到application insights

Azure function v2的示例
host.json
,它可以将跟踪消息记录到应用程序洞察:

APPINSIGHT_INSTRUMENTATIONKEY: <instrumentation key from app insights>
AzureWebJobsDashboard: <storage acct connect string>
AzureWebJobsStorage: <storage acct  connect string>
FUNCTIONS_EXTENSION_VERSION ~3
FUNCTIONS_WORKER_RUNTIME dotnet
{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Information",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace"
    }
  }
}
在Azure portal中,导航到function app settings中的function app->,然后在host.json中将日志级别更改为trace

有关更多详细信息,请参阅本手册,了解如何设置功能v1或v2的日志级别


注意:app insight和Monitor中的调用日志有延迟时间。操作完成后,等待5分钟,然后再次检查。您可以先进行app insight检查。如果app insight没有日志,Monitor将没有。

在文件
host.json
中,用于字段“函数”,将其值设置为Trace。然后可以将其登录到application insights

Azure function v2的示例
host.json
,它可以将跟踪消息记录到应用程序洞察:

APPINSIGHT_INSTRUMENTATIONKEY: <instrumentation key from app insights>
AzureWebJobsDashboard: <storage acct connect string>
AzureWebJobsStorage: <storage acct  connect string>
FUNCTIONS_EXTENSION_VERSION ~3
FUNCTIONS_WORKER_RUNTIME dotnet
{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Information",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace"
    }
  }
}
在Azure portal中,导航到function app settings中的function app->,然后在host.json中将日志级别更改为trace

有关更多详细信息,请参阅本手册,了解如何设置功能v1或v2的日志级别


注意:app insight和Monitor中的调用日志有延迟时间。操作完成后,等待5分钟,然后再次检查。您可以先进行app insight检查。如果app insight没有日志,Monitor将没有日志。

我发现在ehost.json修复了此问题

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false
      }
    },
    "logLevel": {
      "default": "Debug",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace",
    }
  }
}


我发现在host.json中显式禁用application insights采样设置解决了这个问题

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": false
      }
    },
    "logLevel": {
      "default": "Debug",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace",
    }
  }
}


谢谢你的帖子。我尝试了你的建议,没有改变-在函数->监控页面中没有调用跟踪。正如我提到的,我可以在App Insights中看到几乎最新的跟踪消息。我正在部署应用程序服务,这与函数应用程序有什么区别吗?这个问题非常奇怪。你能重新创建一个新函数并重新创建一个新的应用程序吗nsight。我定期通过ARM脚本删除/重新创建。这是否应该作为问题发布到github?您能给我详细的ARM脚本,以便我可以尝试复制您的问题。是的,我可以。我如何将它们发送给您?感谢您的帖子。我尝试了您的建议,在函数->监视器页面中没有更改-没有调用跟踪。正如我提到的,我可以在App Insights中可以看到几乎最新的跟踪消息。我正在部署应用程序服务,这与功能应用程序有区别吗?问题非常奇怪。请重新创建一个新功能并重新创建一个新的App Insights。我定期通过ARM脚本删除/重新创建。这是否应该作为问题发布到github?您能给我详细的ARM脚本吗是的,我可以。我怎样才能把它们交给你呢?