Deploying to Microsoft Azure

Information

PSPDFKit Processor has been deprecated and replaced by PSPDFKit Document Engine. All PSPDFKit Processor licenses will work as before and be supported until 15 May 2024 (we will contact you about license migration). To start using Document Engine, refer to the migration guide. With Document Engine, you’ll have access to robust new capabilities (read the blog for more information).

This guide will walk you through the steps for deploying PSPDFKit Processor to the Microsoft Azure Kubernetes Service with Kubernetes.

Setting Up Azure CLI

To deploy PSPDFKit Processor to the Microsoft Azure Kubernetes Service with Kubernetes, you have to set up the Azure CLI utility to manage your Kubernetes cluster in the command line.

To install Azure CLI, follow the installation instructions from the Azure CLI installation guide.

After you’ve installed Azure CLI, run the following command to log in to Microsoft Azure:

az login

This command will print the URL https://microsoft.com/devicelogin and the code for signing in. Open the URL in your browser and enter the code to sign in to your Microsoft Azure account.

Sign in Page

Creating a Resource Group

To create a resource group, run the following:

az group create -l eastus -n pspdfkitresourcegroup

In this example, we created the resource group in the eastus region with the name pspdfkitresourcegroup. An overview of available regions can be found on Microsoft’s Azure geographies page.

Creating a Kubernetes Cluster

To manage your Kubernetes cluster from the command line, you have to install kubectl:

az aks install-cli

To create a Kubernetes cluster with the name pspdfkitAKScluster, run the following:

az aks create -g pspdfkitresourcegroup --name pspdfkitAKScluster --generate-ssh-keys

ℹ️ Note: Microsoft Azure trials are limited to four vCPUs. aks create needs six vCPUs by default (three nodes × two CPUs of Standard_D2 VM size). To create a cluster within free account limits, we recommend the following to generate a cluster with two nodes each using the default Standard_D2 VM size:

az aks create -g pspdfkitresourcegroup --name pspdfkitAKScluster --generate-ssh-keys --node-count 2

To connect kubectl with your cluster, execute:

az aks get-credentials -g pspdfkitresourcegroup -n pspdfkitAKScluster

Creating a ConfigMap

ConfigMaps allow you to decouple configuration artifacts from image content. To create the pspdfkit-config ConfigMap, run the following command:

kubectl create configmap pspdfkit-config

After the ConfigMap is created, you can edit it with the following:

kubectl edit configmap pspdfkit-config

This will open the created ConfigMap in your editor. Edit the file to match the following file, and replace activation_key with your activation key:

# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving,
# this file will be reopened with the relevant failures.
#
apiVersion: v1
data:
   api_auth_token: secret
   license_key: YOUR_LICENSE_KEY_GOES_HERE
kind: ConfigMap

Don’t change anything that comes after the kind: ConfigMap line, because that part is autogenerated.

Creating Deployments

To run PSPDFKit Processor, you have to define a Deployment for PSPDFKit Processor. Kubernetes Deployments can be configured in a file. To do so, you’ll need to create the configuration for PSPDFKit Processor (processor.yml) and ensure that the pspdfkit/processor image tag corresponds to the latest PSPDFKit Processor version:

apiVersion: v1
kind: Service
metadata:
  name: processor
spec:
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
  selector:
    app: processor
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: processor
spec:
  selector:
    matchLabels:
      app: processor
  template:
    metadata:
      labels:
        app: processor
    spec:
      containers:
        - image: "pspdfkit/processor:2023.11.1"
          name: processor
          env:
            - name: ACTIVATION_KEY
              valueFrom:
                configMapKeyRef:
                  name: pspdfkit-config
                  key: license_key
            - name: API_AUTH_TOKEN
              valueFrom:
                configMapKeyRef:
                  name: pspdfkit-config
                  key: api_auth_token
          ports:
            - containerPort: 5000
              name: processor

To create the Deployments needed to run PSPDFKit Processor, execute:

kubectl create -f ./pspdfkit-processor.yml

Accessing the Processor Service

To access this new Processor instance, you have to get the external IP address that was assigned to the service. Run the following command to view all the Services in your cluster, along with their assigned external IP addresses:

kubectl get services

This will show something like the following:

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
kubernetes   ClusterIP      10.15.240.1     <none>           443/TCP          54m
processor    LoadBalancer   10.15.247.197   12.345.678.910   5000:32393/TCP   1m

Copy the EXTERNAL-IP address from the processor row and use it together with the port 5000 in your web browser. In this example, you’ll use http://12.345.678.910:5000/. This will present you with a welcome message:

PSPDFKit Processor is up and running.

You just confirmed that your Processor instance is up and running. You can now post processing requests. For example:

curl -H "Authorization: Token token=secret" \
  -F file=@demo.pdf \
  -F operations="{\"operations\":[{\"type\": \"rotatePages\",\"pageIndexes\": \"all\",\"rotateBy\": 90}]}" \
  http://12.345.678.910:5000/process \
  --output result.pdf

Limitations

Be aware that this is just an example setup, and we recommend looking deeper into the Microsoft Azure Kubernetes Service for a production-ready setup.