【发布时间】:2021-10-02 09:22:42
【问题描述】:
我有一个使用新运行时版本 3 的 Azure(持久)功能,该功能应该使用 IronPDF 从 URL 生成 PDF。该函数一直失败,并且记录到 Insights 的唯一错误是这样的:
异常:执行函数时出现异常:A_GetPdfDataFromUrl
类型:Microsoft.Azure.WebJobs.Host.FunctionInvocationException
堆栈跟踪
Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时出现异常:A_GetPdfDataFromUrl
---> System.Exception:从“https://www.myurl.com”生成 PDF 时出错
在 .(字符串 ,CefRenderSettings ,CefBrowserSettings )
在 .RenderPdfDocumentFromUri(ChromePdfRenderOptions Options, ChromeHttpLoginCredentials Login, Uri url)
在 IronPdf.Rendering.Abstractions.PdfRenderProxy'2.RenderUrlAsPdf(Uri Url)
在 IronPdf.Rendering.Abstractions.PdfRenderProxy'2.RenderUrlAsPdf(String UrlOrPath)
在 IronPdf.Rendering.Abstractions.PdfRenderProxy'2.c__DisplayClass19_0.b__0()
在 System.Threading.Tasks.Task'1.InnerInvoke()
在 System.Threading.Tasks.Task.c.<.cctor>b__274_0(Object obj)
在 System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(线程 threadPoolThread,ExecutionContext executionContext,ContextCallback 回调,对象状态)
在 System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(线程 threadPoolThread,ExecutionContext executionContext,ContextCallback 回调,对象状态)
在 System.Threading.Tasks.Task.ExecuteWithThreadLocal(任务和 currentTaskSlot,线程 threadPoolThread)
在 D:\a\1\s\Funcs\PdfFunc.cs:line 155 中的 MyFuncs.PdfFunc.GetPdfDataFromUrl(String url) 在 Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker'2.InvokeAsync(Object instance, Object[] arguments) 在 C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors \FunctionInvoker.cs:第 52 行
在 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeWithTimeoutAsync(IFunctionInvoker 调用程序,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,布尔 throwOnTimeout,TimeSpan timerInterval,IFunctionInstance 实例)在 C:\projects\azure-webjobs-sdk-rqm4t\ src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:第 572 行
在 C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host 中的 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx 实例,ParameterHelper parameterHelper,ILogger 记录器,CancellationTokenSource functionCancellationTokenSource) \Executors\FunctionExecutor.cs:第 518 行
在 C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft 中的 Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx 实例,FunctionStartedMessage 消息,FunctionInstanceLogEntry instanceLogEntry,ParameterHelper parameterHelper,ILogger 记录器,CancellationToken cancelToken) .Azure.WebJobs.Host\Executors\FunctionExecutor.cs:第 296 行
不幸的是,IronPDF 日志不会在 Azure 中生成,因为当前版本中存在错误,他们表示将在下一个版本中修复。所以在那之前我无法弄清楚为什么这个简单的代码在 Azure 中失败了。
[FunctionName("A_GetPdfDataFromUrl")]
public async Task<byte[]> GetPdfDataFromUrl([ActivityTrigger] string url)
{
IronPdf.License.LicenseKey = "";
IronPdf.Logging.Logger.EnableDebugging = true;
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
ChromePdfRenderer chromePdfRenderer = new ChromePdfRenderer();
var trackReportPdf = chromePdfRenderer.RenderUrlAsPdf(url);
return trackReportPdf.BinaryData;
}
【问题讨论】:
-
日志文件确实在 Azure 中生成。请参阅:iron.helpscoutdocs.com/article/122-azure-log-files 所有日志都存储在名为 $logs 的容器中的块 blob 中。这是在为存储帐户启用存储分析时自动创建的。 $logs 容器位于存储帐户的 blob 命名空间中,例如:http://.blob.core.windows.net/$logs >.blob.core.windows.net/$logs。
-
@darren “...当为存储帐户启用存储分析时。”您是指分配给 azure 功能的存储帐户吗?
标签: azure pdf azure-functions ironpdf