Python Azure Function 部署成功,模拟工作正常,但出现应用程序错误。

huangapple go评论66阅读模式
英文:

Python Azure Function deployment succeeds, emulation works, but getting application error

问题

I have a Python Azure Function that I've deployed to successfully in the past. Recently, I can't get any deployed code to respond. I'm simply getting ":( Application Error". I haven't found any of the logs useful, but this particular part stood out to me:

我有一个Python Azure函数,过去成功部署过。最近,我无法让任何已部署的代码响应。我只是收到了“:( 应用程序错误”。我没有发现任何日志有用,但是这一部分特别引起了我的注意:

/home/LogFiles/2023_07_13_lw1sdlwk000475_docker.log  (https://gridinspector-dev-eus2-python-func.scm.azurewebsites.net/api/vfs/LogFiles/2023_07_13_lw1sdlwk000475_docker.log)
2023-07-13T15:23:26.437Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 30.6934132 sec
2023-07-13T15:23:41.830Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 46.0863162 sec
2023-07-13T15:23:57.127Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 61.3830012 sec
2023-07-13T15:24:15.070Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 79.3262565 sec
2023-07-13T15:24:30.663Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 94.9192177 sec
2023-07-13T15:24:45.939Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 110.1949702 sec
2023-07-13T15:25:02.172Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 126.4275622 sec
2023-07-13T15:25:07.455Z ERROR - Container gridinspector-dev-eus2-python-func_1_38c6d5de for site gridinspector-dev-eus2-python-func has exited, failing site start
2023-07-13T15:25:07.511Z ERROR - Container gridinspector-dev-eus2-python-func_1_38c6d5de didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2023-07-13T15:25:07.551Z INFO  - Stopping site gridinspector-dev-eus2-python-func because it failed during startup.

I haven't configured any extra networking information, so I'm not sure why that's happening. I'm retrieving that log from the KUDU log stream.

我没有配置任何额外的网络信息,所以我不确定为什么会发生这种情况。我从KUDU日志流中获取了这个日志。

If it helps, this is my host.json. It's the default and it hasn't changed since the inception of the project.

如果有帮助的话,这是我的 host.json。这是默认值,自项目开始以来没有更改。

{
    "version": "2.0",
    "concurrency": {
        "dynamicConcurrencyEnabled": true,
        "snapshotPersistenceEnabled": true
    },
    "extensionBundle": {
      "id": "Microsoft.Azure.Functions.ExtensionBundle",
      "version": "[3.15.0, 4.0.0)"
    },
    "functionTimeout": "00:30:00",
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
            "default": "Information"
        },
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "maxTelemetryItemsPerSecond": 20,
                "evaluationInterval": "01:00:00",
                "initialSamplingPercentage": 100.0,
                "samplingPercentageIncreaseTimeout": "00:00:01",
                "samplingPercentageDecreaseTimeout": "00:00:01",
                "minSamplingPercentage": 0.1,
                "maxSamplingPercentage": 100.0,
                "movingAverageRatio": 1.0,
                "excludedTypes": "Dependency;Event",
                "includedTypes": "PageView;Trace"
            },
            "enableLiveMetrics": true
        }
    },
    "watchDirectories": [
        "src"
    ]
}

Does anyone have any advice or routes for me to diagnose the issue?

有人有任何建议或途径可以帮助我诊断这个问题吗?

Additional useful information:

  • I can emulate this just fine using Azurite and the VS Code tools.
  • I was able, this morning, to successfully deploy an old version of the code, but that seemed to be short-lived and inconsistent.
  • The deployment always succeeds. It's trying to reach the deployment that I can't seem to do.
  • I am not deploying a container. I'm using a Linux app service plan with an Azure Function. I'm ZIP deploying to that Azure Function my Python project.

其他有用的信息:

  • 我可以使用Azurite和VS Code工具很好地模拟这个问题。
  • 今天早上,我成功地部署了旧版本的代码,但似乎是短暂的和不一致的。
  • 部署总是成功的。我无法似乎无法访问部署。
  • 我没有部署容器。我正在使用Linux应用服务计划与Azure函数一起使用。我正在将我的Python项目ZIP部署到Azure函数中。
英文:

I have a Python Azure Function that I've deployed to successfully in the past. Recently, I can't get any deployed code to respond. I'm simply getting ":( Application Error". I haven't found any of the logs useful, but this particular part stood out to me:

/home/LogFiles/2023_07_13_lw1sdlwk000475_docker.log  (https://gridinspector-dev-eus2-python-func.scm.azurewebsites.net/api/vfs/LogFiles/2023_07_13_lw1sdlwk000475_docker.log)
2023-07-13T15:23:26.437Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 30.6934132 sec
2023-07-13T15:23:41.830Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 46.0863162 sec
2023-07-13T15:23:57.127Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 61.3830012 sec
2023-07-13T15:24:15.070Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 79.3262565 sec
2023-07-13T15:24:30.663Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 94.9192177 sec
2023-07-13T15:24:45.939Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 110.1949702 sec
2023-07-13T15:25:02.172Z INFO  - Waiting for response to warmup request for container gridinspector-dev-eus2-python-func_1_38c6d5de. Elapsed time = 126.4275622 sec
2023-07-13T15:25:07.455Z ERROR - Container gridinspector-dev-eus2-python-func_1_38c6d5de for site gridinspector-dev-eus2-python-func has exited, failing site start
2023-07-13T15:25:07.511Z ERROR - Container gridinspector-dev-eus2-python-func_1_38c6d5de didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2023-07-13T15:25:07.551Z INFO  - Stopping site gridinspector-dev-eus2-python-func because it failed during startup.

I haven't configured any extra networking information, so I'm not sure why that's happening. I'm retrieving that log from the KUDU log stream.

If it helps, this is my host.json. It's the default and it hasn't changed since the inception of the project.

{
    "version": "2.0",
    "concurrency": {
        "dynamicConcurrencyEnabled": true,
        "snapshotPersistenceEnabled": true
    },
    "extensionBundle": {
      "id": "Microsoft.Azure.Functions.ExtensionBundle",
      "version": "[3.15.0, 4.0.0)"
    },
    "functionTimeout": "00:30:00",
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
            "default": "Information"
        },
        "applicationInsights": {
            "samplingSettings": {
                "isEnabled": true,
                "maxTelemetryItemsPerSecond": 20,
                "evaluationInterval": "01:00:00",
                "initialSamplingPercentage": 100.0,
                "samplingPercentageIncreaseTimeout": "00:00:01",
                "samplingPercentageDecreaseTimeout": "00:00:01",
                "minSamplingPercentage": 0.1,
                "maxSamplingPercentage": 100.0,
                "movingAverageRatio": 1.0,
                "excludedTypes": "Dependency;Event",
                "includedTypes": "PageView;Trace"
            },
            "enableLiveMetrics": true
        }
    },
    "watchDirectories": [
        "src"
    ]
}

Does anyone have any advice or routes for me to diagnose the issue?

Additional useful information:

  • I can emulate this just fine using Azurite and the VS Code tools.
  • I was able, this morning, to successfully deploy an old version of the code, but that seemed to be short-lived and inconsistent.
  • The deployment always succeeds. It's trying to reach the deployment that I can't seem to do.
  • I am not deploying a container. I'm using a Linux app service plan with an Azure Function. I'm ZIP deploying to that Azure Function my Python project.

Addition 1:
FiddleStix pointed out as comment that I could find logs in App Insights. This is what I found

System.NullReferenceException:
   at Microsoft.Azure.WebJobs.Script.WorkerFunctionMetadataProvider+<GetFunctionMetadataAsync>d__10.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/WorkerFunctionMetadataProvider.cs:79)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.WebHost.FunctionMetadataProvider+<GetFunctionMetadataAsync>d__10.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/FunctionMetadataProvider.cs:45)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.LoadFunctionMetadata (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/FunctionMetadataManager.cs:145)
   at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.GetFunctionMetadata (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/FunctionMetadataManager.cs:89)
   at Microsoft.Azure.WebJobs.Script.ScriptHost.GetFunctionsMetadata (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/ScriptHost.cs:370)
   at Microsoft.Azure.WebJobs.Script.ScriptHost+<InitializeAsync>d__94.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/ScriptHost.cs:286)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.ScriptHost+<StartAsyncCore>d__93.MoveNext (Microsoft.Azure.WebJobs.Script, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script/Host/ScriptHost.cs:258)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Extensions.Hosting.Internal.Host+<StartAsync>d__12.MoveNext (Microsoft.Extensions.Hosting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService+<UnsynchronizedStartHostAsync>d__52.MoveNext (Microsoft.Azure.WebJobs.Script.WebHost, Version=4.22.0.0, Culture=neutral, PublicKeyToken=null: /src/azure-functions-host/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs:328)

Python Azure Function 部署成功,模拟工作正常,但出现应用程序错误。

答案1

得分: 1

  • 应用程序错误 是由许多原因引起的。
  • 但根据您提供的日志,这可能是由于端口问题引起的:

>2023-07-13T15:25:07.511Z 错误 - 容器 gridinspector-dev-eus2-python-func_1_38c6d5de 未响应端口 80 上的 HTTP 心跳,导致站点启动失败。请查看容器日志以进行调试。
2023-07-13T15:25:07.551Z 信息 - 停止站点 gridinspector-dev-eus2-python-func,因为在启动期间失败。

修复此问题的一个解决方法是在应用程序设置中 公开端口 80
导航到您的 function app=> 打开设置=>配置=>添加新的应用程序设置

  • 添加设置 WEBSITES_PORT:80

Python Azure Function 部署成功,模拟工作正常,但出现应用程序错误。

  • 为了跟踪应用程序日志,在 Function App=> 监视=>应用程序服务日志=>选择文件系统 中启用应用程序日志记录。

Python Azure Function 部署成功,模拟工作正常,但出现应用程序错误。

  • 您可以在函数应用的 LogStream 中查看实时日志。
英文:
  • Application Error occurs due to many reasons.
  • But as per your provided logs, it could be due to port issue:

>2023-07-13T15:25:07.511Z ERROR - Container gridinspector-dev-eus2-python-func_1_38c6d5de didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2023-07-13T15:25:07.551Z INFO - Stopping site gridinspector-dev-eus2-python-func because it failed during startup.

One workaround to fix this issue is exposing the PORT 80 in app settings:
Navigate to your function app=> Open Settings=>Configuration=>Add New Application Settings:

  • Add the setting WEBSITES_PORT:80

Python Azure Function 部署成功,模拟工作正常,但出现应用程序错误。

  • And to track application logs, enable application logging in Function App=> Monitoring=>App Service Logs=> Select File System in Application Logging.

Python Azure Function 部署成功,模拟工作正常,但出现应用程序错误。

  • You can see the real-time logs in LogStream of function app.

答案2

得分: 0

我在经过多次尝试和错误后解决了这个问题。您需要启用远程构建以安装requirements.txt中的依赖。此外,.funcignore似乎不像您期望的那样起作用。我切换到使用.artifactignore来忽略可能会引发错误的文件,比如local.settings.json-sample。一旦我做了这两件事,就不再收到运行时错误。

英文:

I figured it out after much trial and error. You need to enable remote builds for the requirements.txt to be installed. In addition, .funcignore apparently doesn't work as you would expect it to. I switched to using a .artifactignore to ignore possibly error-causing files like local.settings.json-sample. Once I did both of these things, I no longer received runtime errors.

huangapple
  • 本文由 发表于 2023年7月13日 23:42:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681201.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定