Can I Run HTML to PDF with .NET on Azure?

Yes. IronPDF can be used to generate, manipulate, and read PDF documents on Azure.

IronPDF has been thoroughly tested on multiple Azure platforms including MVC websites, Azure Functions, and many more.


Step 1

1. Install IronPDF to Get Started

First Install with Nuget: https://www.nuget.org/packages/IronPdf

PM > Install-Package IronPdf

Other options:


How to Tutorial

2. Performance and Azure Tiers

We recommend that Azure B1 hosting levels are very suitable for our end users' rendering needs. If they are creating a high throughput system, this may need to be upgraded.

3. Framework Choice

We have found that IronPDF for Core and for Framework both work on Azure. .NET Standard applications seem to have a small performance advantage on speed and stability, but use more memory in process.

4. Known Issues

SVG fonts rendering is not available on shared hosting plans

One limitation we have found is that the Azure hosting platform does not support servers loading SVG fonts, such as Google Fonts, in their cheaper shared web-app tiers. This is because these shared hosting platforms are not allowed to access windows GDI+ graphics objects for security reasons.

We recommend using a Windows or Linux Docker Container or perhaps a VPS on Azure to navigate this issue where the best font rendering is required.

Azure free tier hosting is slow

Azure free and shared tiers, and the consumption plan, are not suitable for PDF rendering. We recommend Azure B1 hosting/Premium plan, which is what we use ourselves.

Html to PDF is significant ‘work’ for any computer - similar to opening and rendering a web page on your own machine. A real browser engine is used, hence we need to provision accordingly and expect similar render times to a desktop machine of similar power.

5. Docker on Azure

One way to gain control, SVG font access, and the ability to control performance on Azure is to use IronPDF applications and Functions from within Docker Containers.

We have a comprehensive IronPDF Azure Docker tutorial for Linux and Windows instances and it is recommended reading.

6. Official Azure Function Support

As of the 2021.12 release we have official Azure Function support (AzureFunctions V3)

Nuget Setup

The Golden Rule

  • In Azure Publishing Config, “Deploying Azure Functions: make sure “Run from package file” is NOT checked.
  • See attached Images

Working Azure Function Code Example

Tested on Azure Functions v3.3.1.0+ for both Windows and Linux. This example automatically outputs log entries to the built-in Azure logger (see ILogger log).

        [FunctionName("PrintPdf")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            log.LogInformation("Entered PrintPdf API function...");
            IronPdf.Installation.LicenseKey = "XXXX"; // you may enter a license key here!
            IronPdf.Logging.Logger.EnableDebugging = false;
            IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.Custom;
            IronPdf.Logging.Logger.CustomLogger = log;
            Installation.LinuxAndDockerDependenciesAutoConfig = false;
            Installation.ChromeGpuMode = 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);
            }

            return new OkObjectResult("OK");
        }
        [FunctionName("PrintPdf")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            log.LogInformation("Entered PrintPdf API function...");
            IronPdf.Installation.LicenseKey = "XXXX"; // you may enter a license key here!
            IronPdf.Logging.Logger.EnableDebugging = false;
            IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.Custom;
            IronPdf.Logging.Logger.CustomLogger = log;
            Installation.LinuxAndDockerDependenciesAutoConfig = false;
            Installation.ChromeGpuMode = 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);
            }

            return new OkObjectResult("OK");
        }
<FunctionName("PrintPdf")>
Public Shared Async Function Run(<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route := Nothing)> ByVal req As HttpRequest, ByVal log As ILogger, ByVal context As ExecutionContext) As Task(Of IActionResult)
			log.LogInformation("Entered PrintPdf API function...")
			IronPdf.Installation.LicenseKey = "XXXX" ' you may enter a license key here!
			IronPdf.Logging.Logger.EnableDebugging = False
			IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.Custom
			IronPdf.Logging.Logger.CustomLogger = log
			Installation.LinuxAndDockerDependenciesAutoConfig = False
			Installation.ChromeGpuMode = Engines.Chrome.ChromeGpuModes.Disabled
			Try
				log.LogInformation("About to render pdf...")
				Dim renderer As New ChromePdfRenderer()
				Using doc = renderer.RenderUrlAsPdf("https://www.google.com/")
					log.LogInformation("finished rendering pdf...")
					Return New FileContentResult(doc.BinaryData, "application/pdf") With {.FileDownloadName = "google.pdf"}
				End Using
			Catch e As Exception
				log.LogError(e, "Error while rendering pdf", e)
			End Try

			Return New OkObjectResult("OK")
End Function
VB   C#