Search code examples
c#azurereporting-servicestelerikazure-web-app-service

Telerik Reporting produces pdf locally, but not on Azure


I am rendering some simple text to a PDF in C# using Telerik:

using Telerik.Reporting;
using Telerik.Reporting.Processing
...
ReportProcessor reportProcessor = new ReportProcessor();
InstanceReportSource instanceReportSource = new InstanceReportSource();
instanceReportSource.ReportDocument = new MyReport();
RenderingResult result = reportProcessor.RenderReport("PDF",    instanceReportSource, null);

This works great locally.

I've set up an Azure app service, and I am getting the following error when I run reportProcessor.RenderReport():

An error has occurred while rendering the report: System.ArgumentException: Parameter is not valid.
  at System.Drawing.Graphics.GetHdc()
  at Telerik.Reporting.Pdf.PdfContext..ctor()
  at Telerik.Reporting.Pdf.PdfDocument..ctor()
  at Telerik.Reporting.ImageRendering.DocumentPdf.FindOrCreateDocument()
  at Telerik.Reporting.ImageRendering.DocumentPdf..ctor(PdfRenderingContext context, IMeasureContext measureContext)
  at Telerik.Reporting.ImageRendering.PdfReport.CreateDocument(IDictionary renderingInfo, IDictionary deviceInfo, CreateStream createStreamCallback, PageSettings pageSettings)
  at Telerik.Reporting.BaseRendering.DocumentRenderingExtensionBase.CreateWriter(IDictionary renderingContext, IDictionary deviceInfo, CreateStream createStreamCallback, PageSettings pageSettings)
  at Telerik.Reporting.ImageRendering.PdfReport.CreateWriter(IDictionary renderingContext, IDictionary deviceInfo, CreateStream createStreamCallback, PageSettings pageSettings)
  at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)

I feel like this might be an issue with the way I've configured my Azure app service. Here is my configuration: - Location: West US (we're based in Utah) - "F1 Free" pricing tier (also West US) with 1 GB Storage and used by 2 App Services

Is my Azure app service configuration missing something?


Solution

  • Azure's free pricing tier does not currently support GDI+, which Telerik Reporting uses to render to PDF. Your Azure App Service must be using Basic or Standard mode, not Free or Shared. Microsoft deployed this feature in 2014, mentioned in the Telerik forums here:

    http://www.telerik.com/forums/out-of-memory-in-azure-websites#yDA-ydAnBEOF0qKbHljCvw