Can I Run HTML to PDF with .NET on Azure?
Yes. IronPDF can use 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.
1. Install IronPDF to Get Started
First Install with Nuget: https://www.nuget.org/packages/IronPdf
PM > Install-Package IronPdf
- Manually install using DLL download.
- Install for Docker, Linux, Mac.
- Use our platform specific Nuget packages.
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.
Azure Function v1 and v2 do not support System.Drawing.Common
Older Azure function may report this issue due to a lack of GDI+ support:
System.Drawing.Common: System.Drawing is not supported on this platform.
As of 2021 you can switch your Azure Function to v3.
- In the "Azure Function App" settings panel select Runtime Version = 3
- With this setup, your code runs in a sandbox that supports .Net Core 2, 3 and dotNet 5.
- The error goes away
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. These excerpts may help you get started.
Example DockerFile for Linux
This is an example windows container DockerFile for .NET Standard (2.0+) and .NET 4.0+ applications.
# escape=` FROM mcr.microsoft.com/dotnet/core/runtime:3.1 # Mount folder for an application VOLUME /app WORKDIR /app
Example DockerFile for Windows
This is an example Windows container Dockerfile for .NET Standard (2.0 to 3.1+ as of March 2020) and .NET 4.0+ applications.
# escape=` FROM mcr.microsoft.com/windows/servercore:ltsc2019 # Create folder for .NET Core installer WORKDIR /dotnet-install # Download .NET Core installer ADD https://download.visualstudio.microsoft.com/download/pr/ff658e5a-c017-4a63-9ffe-e53865963848/15875eef1f0b8e25974846e4a4518135/dotnet-hosting-3.1.3-win.exe dotnet-installer.exe # Execute .NET Core installer USER ContainerAdministrator RUN dotnet-installer.exe /install /quiet /norestart /log dotnet-install.log || exit 0 # Print installation log to the Console USER ContainerUser RUN type dotnet-install.log # Mount application folder VOLUME c:\app