This is a Visual Studio 2019 project that demonstrates generating a PDF with Prince in C# / ASP.NET Core. It uses the Prince C# / .Net Wrapper. It has been confirmed to work when deployed as an App Service on Microsoft Azure.
Follow these steps to deploy this project to Microsoft Azure:
- Clone the repository:
git clone https://github.com/yeslogic/azure-prince-example.git
- Open the project in Visual Studio, selecting the
PrinceApplication1.sln
file. - In the Solution Explorer, right-click on
PrinceApplication1
and choose "Publish...".
- In the Publish window that appears, select Azure as the Target and click "Next".
- Choose "Azure App Service (Windows)" as the Specific Target.
- Create or sign in to your Azure account.
When signed in, click "Create a new Azure App Service...".
- Pick a name, this will be used as the sub-domain when deployed.
E.g. a name of
PrinceApplication2
gets deployed to https://princeapplication2.azurewebsites.net/. Choose a subscription, create or choose an existing resource group, and hosting plan. Click "Create", then click "Finish".
- Click the Publish button in the main Publish view.
- Your browser should open when publishing completes. Add
/prince
to the URL and you should see a PDF generated by Prince.
Two tools that are useful for debugging Prince in Azure are the logs and the console. This section shows how to use these.
- Sign in to the Azure portal and navigate to App Services.
- Click on the App Service you want to inspect.
Logs from the App Service can be viewed in the Azure portal. However, they must be enabled first:
- Sign in and navigate to your App Service.
- In the side bar click on "App Service Logs".
- Enable "Application Logging (Filesystem)".
- Set the Level to "Information", and click "Save".
- Wait for the notification that logging is enabled.
- Sign in and navigate to your App Service.
- In the side bar click on "Log stream". Now when new requests are made you
will see the logs.
- Sign in and navigate to your App Service.
- In the side bar click on "Console". You can now run commands and inspect the
deployed files.
The source code in this repository is licensed under the Apache 2.0 license.
The Inter font family contained in PrinceApplication1/fonts is Copyright 2016-2020 The Inter Project Authors. "Inter" is trademark of Rasmus Andersson. This Font Software is licensed under the SIL Open Font License, Version 1.1. See PrinceApplication1/fonts/LICENSE.