诊断“功能主机未运行".在码头工人 [英] Diagnose 'Function host is not running.' in docker

查看:69
本文介绍了诊断“功能主机未运行".在码头工人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我们基于dotnet的多个功能应用程序(v3)迁移到Docker容器.为此,我们使用来自 mcr.microsoft.com/azure-functions/dotnet 作为基础

I am trying to migrate several of our dotnet based function-apps (v3) to docker containers. For this we use images from mcr.microsoft.com/azure-functions/dotnet as a base

当使用docker run在本地进行测试时,我经常遇到以下问题:对容器的http调用返回错误功能主机未运行,并结合了以下Docker CLI输出:

When testing locally using docker run, I often have the problem a http call to the container returns error Function host is not running combined with the following Docker CLI output:

Starting OpenBSD Secure Shell server: sshd.
Hosting environment: Development
Content root path: /home/site/wwwroot
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

这仅表示该功能应用不会加载/启动,但真正的原因仍然隐藏.我一直在尝试获取更多的日志记录/诊断数据,以确定根本原因,但到目前为止仍失败.结果,每次发生这种情况时,我都必须开始一个疲惫的反复试验测试循环.到目前为止,这些情况使我花了几天(几周?)的时间

This simply means the function app won't load / start but the real cause stays hidden. I have been trying to get more logging/ diagnostics data to determine the underlying cause but failed so far. As a result, I have to start an exhausting trial-and-error test loop, everytime this situation occurs. These situations have taken me several days (weeks?) so far

问题:发生此错误时如何获取更多诊断数据?

Question: How do I get more diagnostic data when this error occurs?

[UPDATE] Dockerfile:

[UPDATE] the Dockerfile:

FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice AS base
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:3.1-buster AS build
WORKDIR /src
# provide access to private nuget (source)
ARG FEED_SOURCE
ARG FEED_ACCESSTOKEN
RUN dotnet new nugetconfig
RUN dotnet nuget add source %FEED_SOURCE% -n PrivateFeed -u docker -p %FEED_ACCESSTOKEN% --store-password-in-clear-text --configfile nuget.config
# Restore all nuget packages by the related .csproj files
COPY ["MyCompany.MyApp.FunctionApp/MyCompany.MyApp.FunctionApp.csproj", "MyCompany.MyApp.FunctionApp/"]
RUN dotnet restore "MyCompany.MyApp.FunctionApp/MyCompany.MyApp.FunctionApp.csproj"

# Copy the rest of the project-folder's content
COPY ["MyCompany.MyApp.FunctionApp", "MyCompany.MyApp.FunctionApp"]
# build the app project
WORKDIR "/src/MyCompany.MyApp.FunctionApp"
RUN dotnet build -c Release --no-restore

FROM build AS publish
RUN dotnet publish -c Release --no-build -o /app/publish

FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AZUREFUNCTIONSJOBHOST__LOGGING__CONSOLE__ISENABLED=true

推荐答案

功能主机未运行

这通常意味着您的功能应用程序中存在一些错误的配置,导致主机无法启动.

This usually means that there is some bad configuration in your function app which is causing the host to fail to start up. Things like having an invalid host.json or an invalid proxies.json file are a possible cause.

您可以参考这篇文章:

功能主机未运行

如果要获取更多诊断日志,可以将 Azure函数部署到 Azure门户,然后使用诊断设置监视您的功能.

If you want to get more diagnostic logs, you can deploy the Azure function to the Azure portal, and then use the diagnostic setting to monitor your function.

请参阅此文档:

https://docs.microsoft.com/zh-CN/azure/azure-functions/functions-monitor-log-analytics?tabs=csharp

这篇关于诊断“功能主机未运行".在码头工人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆