I've created an Azure Function App in Visual Studio 2019 on .NET Core 2.1. My Function takes a set of data (less than 1 MB) and generates a PDF report of the data based on an HTML template (using the NuGet package OpenHtmlToPdf).
The function is triggered by an Azure Service Bus Queue.
It works perfectly when I run the function app locally, with my local.settings.json pointing to the queue on Azure. I send a message to the queue and everything works/completes as expected within a matter of seconds. But when I deploy it to Azure and when it is triggered, it times out during the PDF generation process after working for several minutes. Everything else works up until it reaches this block of code (after the LogInformation() call):
_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");
It never reaches the second LogInformation("Finished....") call, timing out before that point while executing the Pdf calls.
Here is a sample of the App Insights log (first my logged message, then the timeout exception):
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
And here are the actual timeout exception details:
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
And yes, I have tried increasing the timeout value (up to our service plan's maximum of 10 minutes) - but it still times out. Even though it only takes a few seconds to execute on my local machine.
In addition, I have checked, double-checked, triple-checked all the Function App configuration settings. (I should mention that my company has several other Azure Function Apps written in .NET Core 2.1 that work fine).
What am I doing wrong? Is is simply that Azure Functions are not meant to handle resource-intensive operations such as generating PDFs?
I am facing a similar problem which also demands intensive CPU. Seems to me that the problem is something in the Azure Functions side. What you can do is use a Durable Functions and pass this PDF generation to an activity. I am not sure if it will solve for you or not, but worths a try.
So we have our Twilio callbacks setup to validate incoming requests, via the TwilioRequestValidator documented here.
However, something we're seeing, is that the production server will run for weeks with no problems, and then suddenly start failing with a CryptographicException. This causes all incoming Twilio requests to fail.
We have a call-stack (thanks to Azure Application Insights):
System.Security.Cryptography.CryptographicException:
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Security.Cryptography.Utils.HashData (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Security.Cryptography.SHA1CryptoServiceProvider.HashCore (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Security.Cryptography.HashAlgorithm.TransformBlock (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Security.Cryptography.HMAC.HashCore (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at System.Security.Cryptography.HashAlgorithm.ComputeHash (mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at Twilio.Security.RequestValidator.GetValidationSignature (Twilio, Version=5.14.1.0, Culture=neutral, PublicKeyToken=null)
at Misc.TwilioRequestValidator.ValidateTwilioRequestAttribute.IsValidRequest (RCHHRATool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
at Misc.TwilioRequestValidator.ValidateTwilioRequestAttribute.OnActionExecuting (RCHHRATool, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters.InvokeActionMethodFilterAsynchronouslyRecursive (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__31 (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.Begin (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeActionMethodWithFilters (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21.<BeginInvokeAction>b__19 (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.Begin (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1c (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1.CallBeginDelegate (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.Begin (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Controller.BeginExecuteCore (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.Begin (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Controller.BeginExecute (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4 (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncVoid`1.CallBeginDelegate (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResultBase`1.Begin (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication+<>c__DisplayClass285_0.<ExecuteStepImpl>b__0 (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStepImpl (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
at System.Web.HttpApplication.ExecuteStep (System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
And we have some application code, here:
[AttributeUsage(AttributeTargets.Method)]
public class ValidateTwilioRequestAttribute : ActionFilterAttribute
{
private readonly RequestValidator _requestValidator;
public ValidateTwilioRequestAttribute()
{
var authToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
_requestValidator = new RequestValidator(authToken);
}
public override void OnActionExecuting(ActionExecutingContext actionContext)
{
var context = actionContext.HttpContext;
if (!IsValidRequest(context.Request))
{
actionContext.Result = new HttpStatusCodeResult(HttpStatusCode.Forbidden);
}
base.OnActionExecuting(actionContext);
}
private bool IsValidRequest(HttpRequestBase request)
{
var signature = request.Headers["X-Twilio-Signature"];
Debug.WriteLine(request.Headers["X-Twilio-Signature"]);
//var requestUrl = request.RawUrl;
var requestUrl = rewriteUri(request.Url.AbsoluteUri);
Debug.WriteLine("URI is: " + rewriteUri(request.Url.AbsoluteUri));
return _requestValidator.Validate(requestUrl, request.Form, signature);
}
private string rewriteUri(string absoluteUri)
{
//check to make sure we're not replacing 'https' with 'httpss'
if (!absoluteUri.Contains("https"))
{
return Regex.Replace(absoluteUri, #"http", "https");
}
return absoluteUri;
}
}
Any ideas on what could be causing this? Ideally, I'd like to handle this exception state, but I'm not sure how to handle the exception without knowing what the cause is.
EDIT: I'm getting this error message when I drill into the exception in application insights:
"Hash not valid for use in specified state."
EDIT #2: A quick search on that error messages digs up this interesting discussion on the thread safety of the Cryptography object.
Looks like this is a bug in the Twilio-csharp library. I believe they're using their Sha1 member in a non-thread safe manner.
I've hacked up a solution to re-init the class in the event of a CryptographicException. Since a server restart is fixing the issue, I think a force re-init of the class is called for.
try
{
return _requestValidator.Validate(requestUrl, request.Form, signature);
}
catch (CryptographicException e)
{
//if the request fails, re-init the class and try again
var authToken = ConfigurationManager.AppSettings["TwilioAuthToken"];
_requestValidator = new RequestValidator(authToken);
return IsValidRequest(request);
}
EDIT: Worth noting that this fix is causing knock-on issues related to the non-thread safe manner in which the library is used.
I am trying to understand what causes the The remote server returned an error: (409) Conflict Exception.
I am writing lines to an AppendBlob by acquiring a lease, appending the text, and breaking the lease, like so. The error only happens every now and then, so I am curious what scenario would cause it to happen. My suspicion would be something may happen if multiple users hit the endpoint where this code executes and somehow to a call to acquire a lease happens at the same time.
// Get the AppendBlob reference
CloudAppendBlob blob = ….
// Acquire a lease on the blob until a call to breaking the lease is made
string leaseId = Guid.NewGuid().ToString();
await blob.AcquireLeaseAsync(null, leaseId);
// Append a new entry to the blob
await blob.AppendTextAsync(
textToBeAppended,
Encoding.UTF8,
new AccessCondition { LeaseId = leaseId },
new BlobRequestOptions(),
new OperationContext());
// break the lease on the blob
await blob.BreakLeaseAsync(null);
The Failed Method is Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException.
I see from telemetry that a call to PUT on the blob initially fails with the 409 status code and the exception above, but immediately after a successful PUT call with a 202 result code occurs. I'm assume Azure Storage is doing a retry, however I do not see the line of text in the file it was supposed to be appended to.
Here is the full call stack if that is helpful, I am not sure what the meaning of ProcessExpectedStatusCodeNoException is from this stack trace.
Microsoft.WindowsAzure.Storage.StorageException: at
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync
(Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35Microsoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
c:\Program Files
(x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.csMicrosoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 50)
at
Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions+<>c__DisplayClass2`1.b__0
(Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35Microsoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
c:\Program Files
(x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.csMicrosoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 69)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
(mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089) at
Microsoft.Community.Data.Providers.BlobStorageProvider+d__1.MoveNext
(Microsoft.Community.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=nullMicrosoft.Community.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null:
C:\BA\813\s\Microsoft.Community\Microsoft.Community.Data\Providers\BlobStorageProvider.csMicrosoft.Community.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 67) at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
(mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089) at
Microsoft.Community.Data.Providers.BlobStorageProvider+d__1.MoveNext
(Microsoft.Community.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=nullMicrosoft.Community.Data, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null:
C:\BA\813\s\Microsoft.Community\Microsoft.Community.Data\Providers\BlobStorageProvider.csMicrosoft.Community.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 72) at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw
(mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification
(mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089) at
Microsoft.Community.Web.Repositories.AzureMLRecommendationsRepository+d__6.MoveNext
(Microsoft.Community.Web, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=nullMicrosoft.Community.Web, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null:
C:\BA\813\s\Microsoft.Community\Microsoft.Community.Web\Repositories\AzureMLRecommendationsRepository.csMicrosoft.Community.Web,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 95)
Inner exception System.Net.WebException handled at
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync:
at
Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException
(Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35Microsoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
c:\Program Files
(x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Shared\Protocol\HttpResponseParsers.Common.csMicrosoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 54)
at
Microsoft.WindowsAzure.Storage.Blob.CloudBlob+<>c__DisplayClass39.b__38
(Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35Microsoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
c:\Program Files
(x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.csMicrosoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
3830) at
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse
(Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35Microsoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
c:\Program Files
(x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.csMicrosoft.WindowsAzure.Storage,
Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35:
299)
I'm wondering why you need to lease the blob and then append the text to the blob. If there are multiple writers simultaneously, it's EXPECTED that you'll meet (409) Conflict in your code.
As you can see in the official doc, acquiring lease (B) when a blob is still being leased by lease (A) will encounter 409 error:
Basically, blob lease is to achieve exclusive write access on a blob, it's inappropriate to use blob lease if you want to append against a blob from multiple writers simultaneously.
What are you afraid of if the AcquireLease and BreakLease operations are removed from your code? To be honest, I don't see any harm.
Sounds like an issue with with concurrency possibly:
Breaks the lease, if the blob has an active lease. Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not required to specify a matching lease ID. When a lease is broken, the lease break period is allowed to elapse, during which time no lease operation except break and release can be performed on the blob. When a lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired.
https://learn.microsoft.com/en-us/rest/api/storageservices/lease-blob#outcomes-of-use-attempts-on-blobs-by-lease-state
If you look at link above you will see a huge table on how 409s can occur.
Can you run a fiddler to get the trace on inner exception?
i have been trying to figure this out with my co-workers for a while now.
i use Ngen to Make Native images and boost my Applications performance on the clients.
lets assume the Exe Filename is Example.exe
what i try to do in the app is that i do ngen install example.exe,and the ngen will install native images for the assebmlies
however here is the problem :
if i try an Elevated CMD and run C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen Display example.exe
the example.exe file name and the version of the native image is displayed,however,using the following code which does the same thing in the windows forms c#,it does not display the filename and version of the example.exe file,and displays the dependencies instead,such as Telerik and so on.
so my question is why does the CMD return the correct result while the process returns the dependencies instead of the filename and version itself?
here is some of my code:
public static bool Run()
{
var f = new Loading();
bool state = false;
var b = new BackgroundWorker();
string runtimeStr = RuntimeEnvironment.GetRuntimeDirectory();
string ngenStr = Path.Combine(runtimeStr, "ngen");
Process process = new Process
{
StartInfo =
{
FileName = ngenStr,
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = false
}
};
if (Environment.OSVersion.Version.Major >= 6)
{
process.StartInfo.Verb = "runas";
}
process.StartInfo.Arguments = "display " + Application.ProductName;
process.Start();
// process.WaitForExit();
string stdoutx = process.StandardOutput.ReadToEnd();
process.WaitForExit();
}
however the stdoutx string does not contain the example.exe filename or version
EDIT : examples of what should be and what is :
this is what the cmd returns which is the correct result :
Example, Version=1.0.0.19, Culture=neutral, PublicKeyToken=null <debug>
this is what is :
Microsoft (R) CLR Native Image Generator - Version 4.6.79.0
Copyright (c) Microsoft Corporation. All rights reserved.
NGEN Roots:
C:\Project\Example\bin\Debug\Example.EXE
NGEN Roots that depend on "Example":
C:\Project\Example\bin\Debug\Example.EXE
Native Images:
Klik.Windows.Forms.EntryLib.V2.2008, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
NCalc, Version=1.3.8.0, Culture=neutral, PublicKeyToken=973cde3f1cafed03
Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
RedGate.Migrations.Core, Version=1.0.0.1401, Culture=neutral, PublicKeyToken=7f465a1c156d4d57 <debug>
RedGate.Shared.ComparisonInterfaces, Version=1.0.2.278, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
RedGate.Shared.SQL, Version=9.9.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
RedGate.Shared.Utils, Version=9.9.0.0, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
RedGate.SOCCompareInterface, Version=3.0.50.59, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
RedGate.SQLCompare.ASTParser, Version=11.0.0.414, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
RedGate.SQLCompare.Engine, Version=11.1.0.2, Culture=neutral, PublicKeyToken=7f465a1c156d4d57 <debug>
RedGate.SQLCompare.Rewriter, Version=11.1.0.2, Culture=neutral, PublicKeyToken=7f465a1c156d4d57
System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data.SQLite, Version=1.0.85.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Threading, Version=1.0.2856.102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Telerik.Reporting, Version=9.0.15.324, Culture=neutral, PublicKeyToken=a9d7983dfcc261be
Telerik.ReportViewer.WinForms, Version=9.0.15.324, Culture=neutral, PublicKeyToken=a9d7983dfcc261be
Telerik.WinControls.ChartView, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e
Telerik.WinControls, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e
Telerik.WinControls.GridView, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e
Telerik.WinControls.Themes.Office2010Black, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e
Telerik.WinControls.Themes.Office2010Silver, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e
Yes, you are not doing this correctly. The syntax of the command you are using is:
ngen.exe display [assemblyName | assemblyPath]
Note the difference between assemblyName and assemblyPath. When you ran it from cmd.exe you typed "example". And thus specified the (partial) assembly name. In your code, you used "example.exe". And the Environment.CurrentDirectory is set correctly by accident, a common accident. So Ngen.exe can find the file and it gets chatty. Listing not just the assembly name but also the native images for all of its dependencies. Like Klik.Windows.Forms.EntryLib etcetera.
Not the only problem, note that you specified the partial assembly name. You want to make sure that the specific version of your assembly was ngen-ed. Make the code look like this instead:
process.StartInfo.Arguments = "display \"" +
System.Reflection.Assembly.GetEntryAssembly().FullName + "\"";
And test it with Project > Properties > Debug tab > untick the "Enable the Visual Studio hosting process" checkbox.
Secondary things to fret about are the bitness of the native images (x86 vs x64) and getting your app elevated so you can install the native images, something you normally only have a shot at when your app is installed.