gpt4 book ai didi

azure - 从 Azure 函数中的 Url 生成 PDF 时出现 IronPDF System.Exception 错误

转载 作者:行者123 更新时间:2023-12-03 00:44:57 28 4
gpt4 key购买 nike

我有一个 Azure(持久)函数,它使用新的运行时版本 3,该函数应该使用 IronPDF 从 URL 生成 PDF。该函数不断失败,记录到 Insights 的唯一错误如下:

Exception: Exception while executing function: A_GetPdfDataFromUrl
Type: Microsoft.Azure.WebJobs.Host.FunctionInvocationException


Stack Trace

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: A_GetPdfDataFromUrl
---> System.Exception: Error while generating PDF from 'https://www.myurl.com'
at .(String , CefRenderSettings , CefBrowserSettings )
at .RenderPdfDocumentFromUri(ChromePdfRenderOptions Options, ChromeHttpLoginCredentials Login, Uri url)
at IronPdf.Rendering.Abstractions.PdfRenderProxy'2.RenderUrlAsPdf(Uri Url)
at IronPdf.Rendering.Abstractions.PdfRenderProxy'2.RenderUrlAsPdf(String UrlOrPath)
at IronPdf.Rendering.Abstractions.PdfRenderProxy'2.<>c__DisplayClass19_0.b__0()
at System.Threading.Tasks.Task'1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
at MyFuncs.PdfFunc.GetPdfDataFromUrl(String url) in D:\a\1\s\Funcs\PdfFunc.cs:line 155at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker'2.InvokeAsync(Object instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 52
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeWithTimeoutAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 572
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 518
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 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;
}

最佳答案

谢谢darren 。将您的建议作为答案发布以帮助其他社区成员。

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

All logs are stored in block blobs in a container named $logs.
This is automatically created when Storage Analytics is enabled for a storage account.
The $logs container is located in the blob namespace of the storage account

回答您的问题Raihan-Iqbal

Do you mean the storage account that is assigned to the azure function

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

有关更多详细信息,请参阅 Iron Log Files .

关于azure - 从 Azure 函数中的 Url 生成 PDF 时出现 IronPDF System.Exception 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69415585/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com