【问题标题】:Function host is not running error in docker rundocker run 中的函数主机未运行错误
【发布时间】:2019-12-27 13:50:41
【问题描述】:

我有一个函数应用,并计划使用 Azure KEDA 进行部署。将当前函数应用程序转换为 docker 并使用 docker run command 在本地进行测试时,出现以下错误。

Function host is not running.

它在 Visual Studio 中调试时有效,但在 Docker 中无效。其他stackoverflow答案建议检查host.json,我试过了,但没有修复。

下面是我的 host.json。

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always",
    "logLevel": {
      "default": "Information",
      "Host": "Error",
      "Function": "Error",
      "Host.Aggregator": "Information"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "maxTelemetryItemsPerSecond": 20
      }
    }
  }
}

Docker 文件

FROM microsoft/dotnet:2.2-sdk AS installer-env

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
    mkdir -p /home/site/wwwroot && \
    dotnet publish Projects/Projectxxx.csproj --output /home/site/wwwroot

# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:2.0-appservice 
FROM mcr.microsoft.com/azure-functions/dotnet:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

【问题讨论】:

  • 这能回答你的问题吗? Function host is not running
  • 不,已经看过了。
  • Related 没有回答你的问题;你能告诉我们你尝试了什么,这样我们就不会浪费任何人的时间了吗?您的帖子缺少这些详细信息,并且会很有帮助...另一方面,主机日志文件呢,它们告诉您什么?
  • 它在 docker 中,所以我看不到日志文件。我已经尝试了您建议的答案中发布的所有步骤。
  • 可能也值得发布您的 Docker 文件?

标签: c# azure docker azure-functions serverless


【解决方案1】:

我做了两件事让它发挥作用。

  • <PackageReference Include="WindowsAzure.Storage" Version="9.3.2" /> 添加到.csproj

  • 遗漏了一些环境变量。在 startup.cs 中使用的 docker run -e 环境参数中缺少一些应用程序设置

【讨论】:

  • 我很好奇;您究竟是如何发现问题的原因的?我经常遇到这个问题(请参阅[Diagnose 'Function host is not running.' in docker][1])[1]:stackoverflow.com/questions/67019463/…
  • 这是反复试验,幸运的是遇到了解决方案
  • 所以没有办法从失败的函数运行时获取日志?
猜你喜欢
  • 1970-01-01
  • 2022-06-23
  • 2022-09-30
  • 2019-12-04
  • 1970-01-01
  • 2017-11-10
  • 1970-01-01
  • 1970-01-01
  • 2019-04-07
相关资源
最近更新 更多