Author Archives: Jeff

Azure Storage Caching and Compression – The Missing Piece

I’ve written and used a lot of the Azure Storage service to work with applications that I’ve built that run in the cloud.  It’s easy enough to use, just throw some files in there and they can be served internally to other applications or you can let the public access them remotely.

Something that always struck me about the public access to the service was that the content was never cached, never compressed, and in general felt like a simple web server delivering content without some of those features that we REALLY like about the modern web.  Adding cache headers and compressing the content will reduce the number of queries to the server and the bandwidth needed to deliver the content when it is requested.

In this post, I’m going to show you how I activated caching and compression for an Azure Storage blob cache that I wanted to use with my web application KlipTok.

Continue reading

How to Configure Extensions for Azure Postgres Flexible Server

I received an offer recently, to migrate my Azure Postgres database to a Flexible Server that would use less resources and cost me less while delivering the same functionality to my application users. Sounds like a GREAT offer, and I proceeded with the migration. Over the last week, I received a bug report and started scratching my head. What could be causing this error? Continue reading

Investigating PDF Generation Software for C# and Azure

Over the last month or two, I’ve been investigating various tools that help .NET developers generate PDF documents.  In particular, I want to be able to create a few PDF reports for the KlipTok application. I compared a set of four popular tools (IronPDF, iText, SyncFusion, and Aspose) and published a YouTube video recently to show off the results:

In this post, I want to show the code I wrote for the winning IronPDF renderer and explore some of the features as I prepare to connect it to render a report from the Streamer Dashboard page of KlipTok.

Why not just print a PDF of the dashboard page?

The dashboard on KlipTok is rendered by JavaScript and WebAssembly.  In the tests from the comparison (source code on GitHub) I originally loaded the full-featured sports website with code like this:

When I attempt to simply update this code to render KlipTok at, I get the following result:

Simple KlipTok Rendering - only seeing splashscreen

Simple KlipTok Rendering – Only the splash screen renders

Clearly, I need to dig in a little further and just attempting to render the Blazor Webassembly site is not going to work.  I also tried a few configuration options:

No.. no dice. I kept getting the same splashscreen again and again. I tried extending the timeout periods, thinking I had a race condition where the page wasn’t finished rendering. Let’s take a look at some of the IronPDF features that I can use after I do a little refactoring of KlipTok to get this rendering.

Additional IronPDF features are going to allow me to format the new KlipTok dashboard page nicely for printing.  Let’s take a look at some of these features and apply them to the static KlipTok page used for SEO.

IronPDF document rendering options

The first feature I activated was visible in the test code I used above, EnableJavaScript.  This feature is intended to allow websites that layout their pages with a framework like React, Angular, or Vue to perform their layout before the PDF is rendered.

I also attempted to use the RenderDelay feature to render KlipTok.  RenderDelay directs IronPDF to wait a specific number of seconds to wait before rendering a PDF.  Usually, IronPDF will render immediately after the HTML is loaded.

I also added a TextHeader to the code block above.  This is very cool because we can add some information about the content of the page inside the header.  In this case, I added an “As Of” date.  I could also add a TextFooter with similar LeftText, RightText and CenterText options to place content in the footer.  Even BETTER, I can use an HtmlFooter or HtmlHeader to place an HTMLFragment in the header or footer.  I’m going to use a little bit of HTML with the {page} and {total-page} macros to place a pager in the footer of the pages.

There are MarginLeft, MarginRight, MarginTop, and MarginBottom properties that you can use to set those margins around your content in millimeters.  I found a setting of 10mm in IronPDF with a margin of 0px in my HTML content achieved a nice balance between stretching the content to fill the paper and some reading room around the edge of the content.

By default, IronPDF attempts to render a print media version of a website.  You can force the CSS media to screen mode by setting the CSSMediaType to PdfCssMediaType.Screen and you should render the same content in your PDF that you see on the screen.

Additionally, you can force IronPDF to render a smaller version of the website by setting the ViewPort size in pixels with the ViewPortHeight and ViewPortWidth options.  It’s a good idea to tinker with these two settings and the FitToPaperMode option which lets you specify how you would like IronPDF to place content on the page.  I liked setting a large ViewPort and setting FitToPaperMode to FitToPaperModes.AutomaticFit so that the page content will be stretched to fill the ViewPort and then rendered on the page.

Finally, you’re going to want to specify the paper size to render the HTML content to.  With a PaperOrientation setting for landscape vs. portrait, and a PaperSize property as well, you have a wealth of options for the format you wish to deliver.

The SEO-optimized version of KlipTok rendered as a PDF with margins, header, and footer.

The SEO-optimized version of KlipTok rendered as a PDF with margins, header, and footer.

Just the beginning…

I had my problems getting the KlipTok content that was built with Blazor Web Assembly to render using IronPDF.  Fortunately, I’m in a process of refactoring the location and delivery of Blazor components in the application and I can probably move that dashboard content to server-size Blazor and render it in the SEO version of the website.

In my next blog post, I’ll move those components and configure IronPDF to render content as an ASP.NET Core Minimal API running on Azure using the format I just defined in the code above.

KlipTok running on an Android emulator on LInux

I built an Android app on my Linux machine using .NET 7 and MAUI

I’ve been tinkering and preparing to build a mobile app for the KlipTok website for the past few months. KlipTok is a personal project, and a joy to work on when I have an hour here and there to spend on the site. The most requested feature I have, is for a mobile app to complement the site, and this week I started focusing on that effort… and was even able to build an Android app using .NET MAUI, Blazor, and my Linux laptop. In this post, I’ll describe how I went about getting the development environment working on Ubuntu Linux.

NOTE: Your experience might be different

Every Linux system is different, and I can point you in the direction that worked for me.  I cannot guarantee that you will find similar success or answer questions for your configuration.

I started this project on my Twitch stream on Friday December 2nd, and was able to get a simple Blazor MAUI application that played a Twitch clip running on my Windows machine.  I used Visual Studio 2022 and the Android emulator that came with it and was happy to have an initial proof-of-concept application running.

I prefer to use my Linux laptop from KFocus when I am not in my home office. It’s a great machine with plenty of power for development. With a quick web search, I found an article where someone was setting up Android development on Linux.  I read through those steps, updated to .NET 7, and wrote a few scripts to help with my development.  Here’s what I did:

  1. I installed Android Studio from the Ubuntu app repository using the Discover app.
  2. I opened Android Studio and grabbed the SDK folder from the Android SDK Manager tool, depicted below.  In my case, its sitting in /home/csharpfritz/Android/Sdk.  Android Studio SDK Manager screen
  3. Installed the .NET MAUI workload into .NET 7 at the command-line with the command: `sudo dotnet workload install maui-android`
  4. Installed the Android Debug Bridge (ADB) with `sudo apt install adb`
  5. Started and ran the emulator from Android Studio, verifying that it was running with `adb devices`

Android Emulator running on Linux

Now that I have the emulator running, I could build and deploy my application to the emulator with the command:

dotnet build -t:Run -f net7.0-android /p:AndroidSdkDirectory=/home/csharpfritz/Android/Sdk

On first test, it failed miserably and complained about not supporting MacCatalyst and iOS development on Linux.  Not a problem, so I updated the csproj file to have supported frameworks like the following:

<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">

When I now build on Linux, just the Android configuration runs.  I tried to recompile and got errors about the compiler not finding the Java jar tool.  Easy enough, I installed the latest tool with this command:

sudo apt install openjdk-11-jdk-headless

I compiled and was able to deploy to the emulator in 55 seconds!  Progress!

KlipTok running on an Android emulator on LInux

Last steps, I wanted to get the app building and recompiling with dotnet watch.  This way, I can make changes and the app will reflect those changes in the emulator.  My dotnet watch command is:

dotnet watch build -t:Run -f net7.0-android /p:AndroidSdkDirectory=/home/csharpfritz/Android/Sdk

I found that the app didn’t rebuild and deploy when I made changes to the razor files.  Easy enough, I made another addition to my csproj file to include a definition for watching the razor files:

  <Watch Include="**\*.razor" />

With this patched, I was able to build and run the app in watch mode.  As I changed razor files, the app would redeploy to the emulator in 6 seconds!  That’s such a better development experience.  Last thing that I tried, was to add a switch to my script to shut off the analyzers when I’m in watch mode:

dotnet watch build -t:Run -f net7.0-android /p:AndroidSdkDirectory=/home/csharpfritz/Android/Sdk /p:RunAnalyzers=false

That didn’t give me a big boost in performance, but I feel better without the analyzers running when I’m in watch mode.

Have you tried building an Android app on Linux with MAUI?  Do you have any tips or tricks for developers to use in order to have a better experience?  Share with us in the comments below

Introducing KlipTok – Social Media fun for Twitch Clips

For the last year, I’ve struggled with a pair of questions I get from my Twitch and developer communities:

  • How do I make my Twitch channel more discoverable?
  • What is an enterprise scale Blazor application that I can find on the internet?

… and since November 2020, I have been answering both of these questions with the same application, and its called KlipTok.

Fritz introduces KlipTok on the first stream in November 2020

KlipTok is an application that indexes Twitch clips from streamers and presents them in a social media friendly way so that you can catch up on your favorite content, discover new content, and discuss with friends your favorite clips.  KlipTok makes video more fun.

Continue reading