An open API service indexing awesome lists of open source software.

https://github.com/yeslogic/azure-prince-example

Example project using Prince to generate a PDF response that can be deployed as an app service to Microsoft Azure
https://github.com/yeslogic/azure-prince-example

azure csharp dotnet-core pdf prince

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

          

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][dotnet-wrapper].
It has been confirmed to work when deployed as an [App Service] on Microsoft
Azure.

## Contents

* [Deploying to Microsoft Azure](#deploying-to-microsoft-azure)
* [Debugging](#debugging)
* [Logs](#logs)
* [Console](#console)
* [License](#license)

## 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](imgs/1-Publish....png)
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](imgs/2-Publish.png)
5. Choose "Azure App Service (Windows)" as the Specific Target.
![Screenshot of the Publish window showing a list of specific targets](imgs/3-Target.png)
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](imgs/4-Resource%20group.png)
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](imgs/5-Create%20app%20service.png)
8. Click the Publish button in the main Publish view.

![Screenshot of main configuration window](imgs/6-Publish!.png)
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](#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](#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](#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](LICENSE).

The [Inter font family][Inter] contained in
[PrinceApplication1/fonts](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](PrinceApplication1/fonts/LICENSE).

[Inter]: https://github.com/rsms/inter
[dotnet-wrapper]: https://www.princexml.com/doc/server-integration/#the-c-net-wrapper-
[App Service]: https://azure.microsoft.com/en-us/services/app-service/
[Azure portal]: https://portal.azure.com/