Click or drag to resize

Deployment to Azure Container Apps

Azure Container Apps runs container images and scales them with the traffic, down to zero when idle. ExpertPdf Anywhere runs there in a Linux image built from the standard mcr.microsoft.com/dotnet/aspnet image, as its non-root user, with nothing installed.

The image

Reference the packages in the application:

XML
<ItemGroup>
  <PackageReference Include="ExpertPdf.Anywhere.Linux" Version="22.0.0" />
  <PackageReference Include="ExpertPdf.Anywhere.Fonts" Version="22.0.0" />
</ItemGroup>

and publish it into a .NET image:

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish MyApp.csproj -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .
USER app
EXPOSE 8080
ENTRYPOINT ["dotnet", "MyApp.dll"]

See Deployment with Docker for more about images.

Step by step

1. Prepare the subscription (once):

az login
az extension add --name containerapp --upgrade
az provider register --namespace Microsoft.App --wait
az provider register --namespace Microsoft.OperationalInsights --wait

2. Create a resource group and a container registry, and push the image (the registry name is global):

az group create --name expertpdf-rg --location westeurope
az acr create --resource-group expertpdf-rg --name expertpdfregistry \
    --sku Basic --admin-enabled true
az acr login --name expertpdfregistry
docker build --platform linux/amd64 \
    -t expertpdfregistry.azurecr.io/myapp:1 .
docker push expertpdfregistry.azurecr.io/myapp:1

3. Create the environment and wait until it reports Succeeded, which can take several minutes:

az containerapp env create --name expertpdf-env \
    --resource-group expertpdf-rg --location westeurope
az containerapp env show --name expertpdf-env --resource-group expertpdf-rg \
    --query properties.provisioningState

4. Create the container app:

az containerapp create --name expertpdf-app --resource-group expertpdf-rg \
    --environment expertpdf-env \
    --image expertpdfregistry.azurecr.io/myapp:1 \
    --registry-server expertpdfregistry.azurecr.io \
    --target-port 8080 --ingress external --cpu 2 --memory 4Gi \
    --min-replicas 0 --max-replicas 3 \
    --scale-rule-name http --scale-rule-type http \
    --scale-rule-http-concurrency 8
  • --cpu 2 --memory 4Gi is the largest consumption size; Chromium needs both.

  • --scale-rule-http-concurrency 8 starts another replica when one is converting 8 pages, the number ExpertPdf Anywhere converts at once by default.

  • --min-replicas 0 scales to zero when idle, and the first request then waits for a replica to start. Use --min-replicas 1 to keep one ready.

What to expect

Tested (West Europe, consumption profile, 2 vCPU / 4 GiB): every conversion succeeded and every language rendered.

Sample

The ExpertPdf Anywhere samples include this deployment, with a step-by-step README, in the cloud/azure-container-apps folder. The cloud/remote-engine/azure-container-apps folder runs the Chromium engine in a container app of its own instead (see Remote Engine).

See Also