1

我有一个使用新运行时版本 3 的 Azure(持久)功能,该功能应该使用 IronPDF 从 URL 生成 PDF。该函数一直失败,并且记录到 Insights 的唯一错误是这样的:

异常:执行函数时出现异常:A_GetPdfDataFromUrl
类型:Microsoft.Azure.WebJobs.Host.FunctionInvocationException


Stack Trace

Microsoft.Azure.WebJobs.Host.FunctionInvocationException:执行函数时出现异常:A_GetPdfDataFromUrl
---> System.Exception:生成 PDF 时出错'https://www.myurl.com'
at .(String ,CefRenderSettings ,CefBrowserSettings )
,位于 IronPdf.Rendering.Abstractions.PdfRenderProxy'2 的 .RenderPdfDocumentFromUri(ChromePdfRenderOptions Options,ChromeHttpLoginCredentials Login,Uri url)
。 IronPdf.Rendering.Abstractions.PdfRenderProxy'2.RenderUrlAsPdf
(String UrlOrPath) 处的 RenderUrlAsPdf (Uri Url )
在 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 (对象 obj)
在 System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(线程 threadPoolThread,ExecutionContext executionContext,ContextCallback 回调,对象状态)
在 System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(线程 threadPoolThread,ExecutionContext executionContext,ContextCallback 回调,对象状态)
在 System.Threading .Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
在 MyFuncs.PdfFunc.GetPdfDataFromUrl(String url) in D:\a\1\s\Funcs\PdfFunc.cs:第 155 行 Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker'2.InvokeAsync(Object instance, Object[ ] 参数)在 C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeWithTimeoutAsync 的第 52 行( C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs 中的 IFunctionInvoker 调用程序、ParameterHelper parameterHelper、CancellationTokenSource timeoutTokenSource、CancellationTokenSource functionCancellationTokenSource、布尔 throwOnTimeout、TimeSpan timerInterval、IFunctionInstance 实例:第 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:
Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync 的第 518 行(IFunctionInstanceEx 实例,FunctionStartedMessage 消息,FunctionInstanceLogEntry instanceLogEntry,ParameterHelper parameterHelper,ILogger 记录器,CancellationToken cancelToken)在 C:\projects\azure- webjobs-sdk-rqm4t\src\Microsoft.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;
}
4

1 回答 1

4

谢谢达伦。_ 发布您的建议作为帮助其他社区成员的答案。

日志将在 Azure 中生成,所有日志都将存储在一个名为 $logs 的容器中。创建存储帐户时会自动生成容器 $logs。

所有日志都存储在名为 $logs 的容器中的块 blob 中。
这是在为存储帐户启用存储分析时自动创建的。
$logs 容器位于存储帐户的 blob 命名空间中

回答你的问题Raihan-Iqbal

您是指分配给 azure 功能的存储帐户吗

是的,我们创建 Azure Function 时创建的存储帐户,或者它可能是 $logs 容器将自动生成的任何存储帐户。

有关详细信息,请参阅Iron 日志文件

于 2021-10-09T10:29:20.807 回答