c# - 为什么我的 Azure Function App(根据数据生成 PDF 文件)会超时?

标签 c# azure azure-functions

我在 .NET Core 2.1 上的 Visual Studio 2019 中创建了一个 Azure Function App。我的函数获取一组数据(小于 1 MB)并根据 HTML 模板(使用 NuGet 包 OpenHtmlToPdf )生成数据的 PDF 报告。

该函数由 Azure 服务总线队列触发。

当我在本地运行函数应用程序时,它可以完美运行,并且我的 local.settings.json 指向 Azure 上的队列。我向队列发送一条消息,一切都在几秒钟内按预期工作/完成。但是,当我将其部署到 Azure 并触发它时,它在工作几分钟后在 PDF 生成过程中超时。其他一切都会正常工作,直到到达此代码块(在 LogInformation() 调用之后):

                _log.LogInformation("Converting template and content into PDF file...");
                pdf = Pdf
                    .From(content)
                    .OfSize(PaperSize.A4)
                    .WithoutOutline()
                    .WithMargins(1.25.Centimeters())
                    .Portrait()
                    .Comressed()
                    .Content();
                _log.LogInformation("Finished converting template and content into PDF file");

它永远不会到达第二个 LogInformation("Finished...") 调用,在执行 Pdf 调用时在此点之前超时。

以下是 App Insights 日志的示例(首先是我记录的消息,然后是超时异常):

12/4/2019, 2:30:18.351 PM   Converting template and content into PDF file...    1   trace   {"prop__{OriginalFormat}":"Converting template and content into PDF file...","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","Category":"Function.PDFProcessorFunction.User","LogLevel":"Information","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}     PDFProcessorFunction    3f325922eef58b46b2f635d283deeebe    |3f325922eef58b46b2f635d283deeebe.60bad8bb00011f46.     PC  0.0.0.0 df-eo-pdf-queue-function-dev    c8ddc12737b5c414811dd541ac7507946788a5bbd653984da9e4a88632659933    9f5886c8-fb23-4ef3-a0af-5cb7333f460e    df-eo-pdf-queue-function-dev    7a528756-2a38-4511-8b8d-04365870a91c    azurefunctions: 2.0.12888.0 87ec212c-16cc-11ea-888f-5f9ca4eaab67    1   

timestamp [UTC]
2019-12-04T19:30:18.351427Z

message
Converting template and content into PDF file...

severityLevel
1

itemType
trace
customDimensions
{"prop__{OriginalFormat}":"Converting template and content into PDF file...","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","Category":"Function.PDFProcessorFunction.User","LogLevel":"Information","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}

operation_Name
PDFProcessorFunction

12/4/2019, 2:35:14.307 PM   Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.    3   trace   {"prop__{OriginalFormat}":"Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","LogLevel":"Error","Category":"Function.PDFProcessorFunction","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}        PDFProcessorFunction    3f325922eef58b46b2f635d283deeebe    |3f325922eef58b46b2f635d283deeebe.60bad8bb00011f46.     PC  0.0.0.0 df-eo-pdf-queue-function-dev    c8ddc12737b5c414811dd541ac7507946788a5bbd653984da9e4a88632659933    9f5886c8-fb23-4ef3-a0af-5cb7333f460e    df-eo-pdf-queue-function-dev    7a528756-2a38-4511-8b8d-04365870a91c    azurefunctions: 2.0.12888.0 32061e7c-16cd-11ea-ae75-6364d66f68e2    1   

timestamp [UTC]
2019-12-04T19:35:14.307144Z

message
Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.

severityLevel
3

itemType
trace
customDimensions
{"prop__{OriginalFormat}":"Timeout value of 00:05:00 exceeded by function 'PDFProcessorFunction' (Id: 'cab3b347-95d3-45ff-b24d-c7c5048e6a6b'). Initiating cancellation.","HostInstanceId":"fe52d18f-9830-40bc-a92b-f0a90cf37dc9","LogLevel":"Error","Category":"Function.PDFProcessorFunction","ProcessId":"4456","InvocationId":"cab3b347-95d3-45ff-b24d-c7c5048e6a6b"}

operation_Name
PDFProcessorFunction

operation_Id
3f325922eef58b46b2f635d283deeebe

operation_ParentId
|3f325922eef58b46b2f635d283deeebe.60bad8bb00011f46.

client_Type
PC

client_IP
0.0.0.0

cloud_RoleName
df-eo-pdf-queue-function-dev

cloud_RoleInstance
c8ddc12737b5c414811dd541ac7507946788a5bbd653984da9e4a88632659933

appId
9f5886c8-fb23-4ef3-a0af-5cb7333f460e

appName
df-eo-pdf-queue-function-dev

iKey
7a528756-2a38-4511-8b8d-04365870a91c

sdkVersion
azurefunctions: 2.0.12888.0

itemId
32061e7c-16cd-11ea-ae75-6364d66f68e2

itemCount
1

以下是实际的超时异常详细信息:

12/4/2019, 2:09:01.106 PM   Microsoft.Azure.WebJobs.Host.FunctionTimeoutException at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext  Microsoft.Azure.WebJobs.Host.FunctionTimeoutException   Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext   Microsoft.Azure.WebJobs.Host.FunctionTimeoutException   Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction    Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35    Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext   3   [{"severityLevel":"Error","outerId":"0","message":"Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction","parsedStack":[{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext","level":0,"line":660,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":1,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":2,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":3,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":4,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<InvokeAsync>d__27.MoveNext","level":5,"line":576,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":6,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":7,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":8,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":9,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithWatchersAsync>d__26.MoveNext","level":10,"line":532,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":11,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":12,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":13,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":14,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__25.MoveNext","level":15,"line":468,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":16,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":17,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":18,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":19,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":20,"line":278,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":21,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":22,"line":322,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":23,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":24,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":25,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":26,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsyncCore>d__16.MoveNext","level":27,"line":117,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"}],"type":"Microsoft.Azure.WebJobs.Host.FunctionTimeoutException","id":"15999211"}]  exception   {"FormattedMessage":"Executed 'PDFProcessorFunction' (Failed, Id=6b0cebaa-0876-428d-a324-03265563651b)","HostInstanceId":"d7abe331-beea-4165-86b4-0323f307939a","InvocationId":"6b0cebaa-0876-428d-a324-03265563651b","ProcessId":"5856","LogLevel":"Error","Category":"Function.PDFProcessorFunction"} PDFProcessorFunction    3f325922eef58b46b2f635d283deeebe    |3f325922eef58b46b2f635d283deeebe.30b1b04f0e993f4a. PC  0.0.0.0 df-eo-pdf-queue-function-dev    34c90aa5d115bbf81d1cb11cf8ef01321f11d527a73c6ae5f86ec717cb94c776    

timestamp [UTC]
2019-12-04T19:09:01.1061419Z

problemId
Microsoft.Azure.WebJobs.Host.FunctionTimeoutException at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext

type
Microsoft.Azure.WebJobs.Host.FunctionTimeoutException

assembly
Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

method
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext

outerType
Microsoft.Azure.WebJobs.Host.FunctionTimeoutException

outerMessage
Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction

outerAssembly
Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

outerMethod
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext

severityLevel
3
details
[{"severityLevel":"Error","outerId":"0","message":"Timeout value of 00:05:00 was exceeded by function: PDFProcessorFunction","parsedStack":[{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryHandleTimeoutAsync>d__29.MoveNext","level":0,"line":660,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":1,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":2,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":3,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":4,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<InvokeAsync>d__27.MoveNext","level":5,"line":576,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":6,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":7,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":8,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":9,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithWatchersAsync>d__26.MoveNext","level":10,"line":532,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":11,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":12,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":13,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":14,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__25.MoveNext","level":15,"line":468,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":16,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":17,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":18,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.GetResult","level":19,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":20,"line":278,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":21,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<ExecuteWithLoggingAsync>d__19.MoveNext","level":22,"line":322,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw","level":23,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess","level":24,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification","level":25,"line":0},{"assembly":"System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e","method":"System.Runtime.CompilerServices.TaskAwaiter`1.GetResult","level":26,"line":0},{"assembly":"Microsoft.Azure.WebJobs.Host, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35","method":"Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor+<TryExecuteAsyncCore>d__16.MoveNext","level":27,"line":117,"fileName":"C:\\projects\\azure-webjobs-sdk-rqm4t\\src\\Microsoft.Azure.WebJobs.Host\\Executors\\FunctionExecutor.cs"}],"type":"Microsoft.Azure.WebJobs.Host.FunctionTimeoutException","id":"15999211"}]

itemType
exception
customDimensions
{"FormattedMessage":"Executed 'PDFProcessorFunction' (Failed, Id=6b0cebaa-0876-428d-a324-03265563651b)","HostInstanceId":"d7abe331-beea-4165-86b4-0323f307939a","InvocationId":"6b0cebaa-0876-428d-a324-03265563651b","ProcessId":"5856","LogLevel":"Error","Category":"Function.PDFProcessorFunction"}

operation_Name
PDFProcessorFunction

operation_Id
3f325922eef58b46b2f635d283deeebe

operation_ParentId
|3f325922eef58b46b2f635d283deeebe.30b1b04f0e993f4a.

client_Type
PC

client_IP
0.0.0.0

cloud_RoleName
df-eo-pdf-queue-function-dev

cloud_RoleInstance
34c90aa5d115bbf81d1cb11cf8ef01321f11d527a73c6ae5f86ec717cb94c776

appId
9f5886c8-fb23-4ef3-a0af-5cb7333f460e

appName
df-eo-pdf-queue-function-dev

iKey
7a528756-2a38-4511-8b8d-04365870a91c

sdkVersion
azurefunctions: 2.0.12888.0

itemId
88417461-16c9-11ea-9da1-1b43f8d3fcf0

itemCount
1

是的,我已经尝试增加超时值(直到我们的服务计划的最大值 10 分钟) - 但它仍然超时。尽管在我的本地计算机上执行只需要几秒钟。

此外,我已经检查、仔细检查、三重检查所有 Function App 配置设置。 (我应该提到,我的公司还有其他几个用 .NET Core 2.1 编写的 Azure Function 应用程序,运行良好)。

我做错了什么?难道只是因为 Azure Functions 不适合处理资源密集型操作(例如生成 PDF)吗?

最佳答案

我面临着类似的问题,也需要密集的CPU。在我看来,问题出在 Azure Functions 方面。您可以做的是使用 Durable Functions 并将此 PDF 生成传递给事件。我不确定它是否能解决您的问题,但值得一试。

关于c# - 为什么我的 Azure Function App(根据数据生成 PDF 文件)会超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59184717/

相关文章:

azure - 应用服务计划上的 Azure 函数的设置 "WEBSITE_CONTENTSHARE"和 "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING"问题

c# - 菜单的 MVVM 最佳实践

c# - BufferManager 在不调用 ReturnBuffer 的情况下调用 TakeBuffer

azure - 如何使用 Terraform 更新 Azure 虚拟中心的路由表和安全配置

azure - VPN 证书在一台计算机上始终声明 "This certificate has an invalid digital signature."

c# - azure 函数queueTrigger 错误 - Microsoft Azure WebJobs SDK '[Hidden Credential]' 连接字符串丢失或为空

c# - Encoding.Default 在 .NET 中如何工作?

创建新的 SqlDataAdapter 时出现 C# InvalidOperationException

azure - 在 Windows Azure 上组织 DDoS 保护

c# - 在 Azure Function 应用程序设置中使用数组