Skip to content

Example project using Prince to generate a PDF response that can be deployed as an app service to Microsoft Azure

License

Notifications You must be signed in to change notification settings

yeslogic/azure-prince-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prince Azure Example

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.

Contents

Deploying to Microsoft Azure

Follow these steps to deploy this project to Microsoft Azure:

  1. Clone the repository: git clone https://github.com/yeslogic/azure-prince-example.git
  2. Open the project in Visual Studio, selecting the PrinceApplication1.sln file.
  3. In the Solution Explorer, right-click on PrinceApplication1 and choose "Publish...".
    Screenshot of menu shown when right-clicking on PrinceApplication1 in the Solution Explorer
  4. In the Publish window that appears, select Azure as the Target and click "Next".
    Screenshot of the Publish window showing a list of possible targets
  5. Choose "Azure App Service (Windows)" as the Specific Target. Screenshot of the Publish window showing a list of specific targets
  6. Create or sign in to your Azure account. When signed in, click "Create a new Azure App Service...".
    Screeshot of App Service section of publishing workflow
  7. 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".
    Screenshot of App Service configuration window
  8. Click the Publish button in the main Publish view.
    Screenshot of main configuration window
  9. Your browser should open when publishing completes. Add /prince to the URL and you should see a PDF generated by Prince.

Debugging

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 and Navigate to Your App Service

  1. Sign in to the Azure portal and navigate to App Services.
    Screenshot of the App Services button on the home page of the Azure portal
  2. Click on the App Service you want to inspect.
    Screenshot of the App Services list in the Azure portal

Logs

Enable Logging

Logs from the App Service can be viewed in the Azure portal. However, they must be enabled first:

  1. Sign in and navigate to your App Service.
  2. In the side bar click on "App Service Logs".
  3. Enable "Application Logging (Filesystem)".
  4. Set the Level to "Information", and click "Save".
    Screenshot of the App Service log settings in the Azure portal
  5. Wait for the notification that logging is enabled.

View Logs

  1. Sign in and navigate to your App Service.
  2. In the side bar click on "Log stream". Now when new requests are made you will see the logs.
    Screenshot of the Log stream in the Azure portal

Console

  1. Sign in and navigate to your App Service.
  2. In the side bar click on "Console". You can now run commands and inspect the deployed files.
    Screenshot of the Console in the Azure portal

License

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.

About

Example project using Prince to generate a PDF response that can be deployed as an app service to Microsoft Azure

Topics

Resources

License

Stars

Watchers

Forks