We have the need to convert our years-old SSRS reports to a newer technology to be able to lift a customer's web app to the Azure cloud. I decided to use DevExpress XtraReports, because there is a nice import feature of existing SSRS reports.
To reduce the overall monthly cost of running the Web App in Azure we decided to use a Azure App Service Linux plan.
The reports need the use of custom fonts, i.e. for displaying barcodes.
However, running XtraReports under Linux really isn't easy.
I've found several information in the DevExpress documentation and Knowledge Base. Though, some information was outdated and didn't work, so my journey was like an adventure.
Two years ago, I managed things getting to work using a custom Dockerfile to install missing Linux packages for the XtraReports.
But today, I didn't want the overhead of creating a custom Dockerfile. I like a solution with plain Azure App Service for Linux, we only deploy a ZIP package that contains our code.
Our web application runs on .NET 8.0 using DevExpress XtraReports v23.2.4 - The WebDocumentViewer
is used to display a report preview to the end user in the browser.
Following are the steps needed to get things working.
Install these nuget packages
- DevExpress.Drawing
- DevExpress.Drawing.Skia
- DevExpress.Reporting.Core
- Microsoft.ICU.ICU4C.Runtime
Force the use of Skia rendering engine
This step is optional, see note below.
In Startup.cs force the use of the new Skia rendering engine
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
DevExpress.Drawing.Internal.DXDrawingEngine.ForceSkia();
}
DevExpress support note: The Skia engine automatically comes into use as long as you do not install libgdiplus.
Add custom font to solution
Add your custom font the Visual Studio solution and make sure it has the "Copy always" output folder property set. I decided to put my fonts in a folder named fonts
.
Use a custom startup script for the App Service
Use a startup script for the App Service to install missing libraries. I decided to name the file run.sh
and put it in my Visual Studio solution. The file should be set to "Copy Always" with no build process.
the contents of the file
#!/bin/bash
apt-get update &&
apt-get install -y libc6 libicu-dev libfontconfig1
cp fonts/FREE3OF9.TTF /usr/local/share/fonts
fc-cache -f -v
dotnet yourwebapp.dll
Configure the App Service to execute the startup script
Set the App Service startup script to our run.sh
in the portal
Helpful resources:
Top comments (0)