skip to Main Content

I’m encountering an issue with a .NET 6.0 (LTS) Azure Function App on Windows, using the elastic premium plan. My application runs locally but not on Azure. I’m following guidelines from IronSoftware on How to Run HTML to PDF with .NET on Azure? and insights from a related Stack Overflow post. Initially, I considered .NET 6.0 (Isolated), but reverted due to reported support issues.

Here’s where I’m at:

Local Development: The app runs locally on .NET 6.0 but had to copy the runtime to the bin directory. I’m unsure if this step is necessary for a publish build or in the Azure environment, since its for Azureite local storage.

Testing: The app works as expected locally.

Deployment: I’ve used a publish profile, disabled ‘run as package’, and added extensive logging. However, the app fails on Azure when running the code from the Ironsoft example.

failing here:

log.LogInformation("About to render pdf...");
ChromePdfRenderer renderer = new ChromePdfRenderer();
using var doc = renderer.RenderUrlAsPdf("https://www.google.com/");
log.LogInformation("finished rendering pdf...");

example code:

log.LogInformation("Entered PrintPdf API function...");
        IronPdf.Installation.LicenseKey = "MYCOMPANYKEY"; 
        IronPdf.Logging.Logger.EnableDebugging = false;
        IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.Custom;
        IronPdf.Logging.Logger.CustomLogger = log;
        Installation.LinuxAndDockerDependenciesAutoConfig = false;
        Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
        try
        {
            log.LogInformation("About to render pdf...");
            ChromePdfRenderer renderer = new ChromePdfRenderer();
            using var doc = renderer.RenderUrlAsPdf("https://www.google.com/");
            log.LogInformation("finished rendering pdf...");
            //return new FileContentResult(doc.BinaryData, "application/pdf") { FileDownloadName = "google.pdf" };
        }
        catch (Exception e)
        {
            log.LogError(e, "Error while rendering pdf", e);
        }

Error Details:

Type Details
Trace Severity level: Information, Message: Entered PrintPdf API function…
Trace Severity level: Information, Message: About to render pdf…
Trace Severity level: Information, Message: ———- Microsoft Windows NT 10.0.20348.0 (C:Program Files (x86)SiteExtensionsFunctions4.27.564bitIronSoftware.log) ———-
Trace Severity level: Information, Message: Initializing local Chrome client…
Trace Severity level: Information, Message: Using deployment directory ‘C:Program Files (x86)SiteExtensionsFunctions4.27.564bit’
Trace Severity level: Information, Message: Creating deployment candidates using root path ‘C:Program Files (x86)SiteExtensionsFunctions4.27.564bit’ (download: True)
Trace Severity level: Information, Message: Creating folder deployments for win-x64
Trace Severity level: Information, Message: Creating embedded deployments for win-x64
Trace Severity level: Information, Message: Creating nuget deployments for IronPdf.Native.Chrome.Windows
Trace Severity level: Information, Message: Creating nuget deployments for IronPdf.Native.Chrome.Windows.Windows
Trace Severity level: Information, Message: Attempting deployment for ‘Chrome’ 2023.11.0.20149 using ‘C:Program Files (x86)SiteExtensionsFunctions4.27.564bit’
Trace Severity level: Information, Message: Failed to locate assembly(s) for deployment ‘C:Program Files (x86)SiteExtensionsFunctions4.27.564bit’ at path ‘C:Program Files (x86)SiteExtensionsFunctions4.27.564bit’
Trace Severity level: Information, Message: IronSoftware.Exceptions.IronSoftwareAssemblyMissingException: Failed to locate ‘IronInterop’ at ‘C:Program Files (x86)SiteExtensionsFunctions4.27.564bit’
Trace Severity level: Information, Message: Successfully located ‘IronInterop’ at ‘C:homesitewwwrootbinruntimeswin-x64native’
Trace Severity level: Information, Message: Determining deployment commands for platform ‘Windows’ v10.0.20348.0
Trace Severity level: Information, Message: Using deployment instructions for ‘default’ v
Trace Severity level: Information, Message: Attempting to load Windows library ‘C:homesitewwwrootbinruntimeswin-x64nativeIronInterop.dll’
Trace Severity level: Information, Message: Attempting to load Windows library ‘C:homesitewwwrootbinruntimeswin-x64nativeIronInterop.dll’
Trace Severity level: Information, Message: Successfully loaded native library from ‘C:homesitewwwrootbinruntimeswin-x64nativeIronInterop.dll’
Trace Severity level: Information, Message: Successfully loaded ‘IronInterop’ version ‘2023.11.0.20149’ from ‘C:homesitewwwrootbinruntimeswin-x64native’
Trace Severity level: Information, Message: Successfully deployed ‘Chrome’ using ‘C:homesitewwwrootbinruntimeswin-x64native’
Trace Severity level: Information, Message: Initializing Chrome renderer for OS Name: Windows, Identifier: win, Version: 10.0.20348.0, VersionName: , Domain: Microsoft.Azure.WebJobs.Script.WebHost, Thread: .NET ThreadPool Worker, Path: C:Program Files (x86)SiteExtensionsFunctions4.27.564bit
Trace Severity level: Information, Message: Creating new job collection resource
Trace Severity level: Information, Message: 21:11:53 (4888): ~ Chrome renderer v2023.11.0.20149~
Trace Severity level: Information, Message: 21:11:53 (4888): register JobManager as publisher for event_readyToInitializeNetworkEventsDevToolsHandler
Trace Severity level: Information, Message: 21:11:53 (4888): [EventRegistry] Register event_readyToInitializeNetworkEventsDevToolsHandler for a publisher
Trace Severity level: Information, Message: 21:11:53 (4888): IsSingleProcess: 0
Trace Severity level: Information, Message: 21:11:53 (4888): Creating Cef proxy controller
Trace Severity level: Information, Message: 21:11:53 (4888): Creating Cef interface
Trace Severity level: Information, Message: 21:11:53 (4888): Created new lifespan events
Trace Severity level: Information, Message: 21:11:53 (4888): Created new load handler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new render handler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new print handler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new dev tools handler
Trace Severity level: Information, Message: 21:11:53 (4888): JobManager subscribes a new sub, eventStr=event_readyToInitializeNetworkEventsDevToolsHandler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new dev tools registration factory
Trace Severity level: Information, Message: 21:11:53 (4888): Created new lifespan handler
Trace Severity level: Information, Message: 21:11:53 (4888): Assigning Cef proxy controller events…
Trace Severity level: Information, Message: 21:11:53 (4888): Created new lifespan events
Trace Severity level: Information, Message: 21:11:53 (4888): Created new load handler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new render handler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new print handler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new dev tools handler
Trace Severity level: Information, Message: 21:11:53 (4888): JobManager subscribes a new sub, eventStr=event_readyToInitializeNetworkEventsDevToolsHandler
Trace Severity level: Information, Message: 21:11:53 (4888): Created new dev tools registration factory
Trace Severity level: Information, Message: 21:11:53 (4888): Created new lifespan handler
Trace Severity level: Information, Message: 21:11:53 (4888): Destroying Cef proxy event handler
Trace Severity level: Information, Message: 21:11:53 (4888): Assigning Cef proxy controller stream provider…
Trace Severity level: Information, Message: 21:11:53 (4888): Initializing Cef proxy controller
Trace Severity level: Information, Message: 21:11:53 (4888): Using subprocess path ‘C:homesitewwwrootbinruntimeswin-x64nativeIronCefSubprocess.exe’
Trace Severity level: Information, Message: 21:11:53 (4888): Using framework path ‘C:homesitewwwrootbinruntimeswin-x64native’
Trace Severity level: Information, Message: 21:11:53 (4888): Using locales path ‘C:homesitewwwrootbinruntimeswin-x64nativelocales’
Trace Severity level: Information, Message: 21:11:53 (4888): Using resources path ‘C:homesitewwwrootbinruntimeswin-x64native’
Trace Severity level: Information, Message: 21:11:53 (4888): Launching child process ‘"C:Windowssystem32inetsrvw3wp.exe" -ap -v -a -h -w -m -t -ta –browser-subprocess-path="C:homesitewwwrootbinruntimeswin-x64nativeIronCefSubprocess.exe" –no-sandbox –lang=en-US –log-file=cef.log –log-severity=disable –resources-dir-path="C:homesitewwwrootbinruntimeswin-x64native" –locales-dir-path="C:homesitewwwrootbinruntimeswin-x64nativelocales" –disable-features=CalculateNativeWinOcclusion,WinUseBrowserSpellChecker,BackForwardCache MYAZUREFUNCTION v4.0 ".pipeiisipm955547cf-bd85-45ba-a205-cfc9ce34ab42" "D:DWASFilesSitesMYAZUREFUNCTIONConfigapplicationhost.config" "D:DWASFilesSitesMYAZUREFUNCTIONConfigrootweb.config" 0
Trace 1:11:53.244 PM Trace Severity level: Information, Message: 21:11:53 (4888): gpu_mode: ‘0’

It looks like it fails on the subprocess launch in the second to last trace, but hard exits without hitting the try catch.

Given this context, I have one question:

What could be causing the IronPdf.ChromePdfRenderer to fail on Azure, despite functioning locally?
Any insights or suggestions for troubleshooting this issue would be greatly appreciated.

2

Answers


  1. Based on the details you’ve provided, there are a few potential causes. The main thing would be that Functions run in a sandbox in Azure and do not natively run on Windows. This sandbox will restrict certain operations required by IronPdf, like launching a subprocess or accessing certain system resources. Several tools allow you to run Functions on your Windows machine, Azure Functions Core Tools, and through the Windows Subsystem for Linux.

    Azure Functions – How it works azure.microsoft.com

    Azure WebApp Sandbox – Github

    Login or Signup to reply.
  2. Adding this line resolved a similar issue running in App Service:

    IronPdf.Installation.SingleProcess = true;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search