I am using a the Aspose PDF library that relies on System.Drawing.Common, and running it on .Net Core 2.1. on Linux. I know this will not work in the sandbox, so I'm trying with a custom Docker image (installing libgdiplus, libc6-dev and ttf-mscorefonts-installer as instructed by e.g. Aspose).
I got it working in a dockerized Web API as a Web App, but when used as an Azure Function the calls fail with PlatformNotSupportedException:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: xxx---> System.PlatformNotSupportedException: System.Drawing is not supported on this platform.
Related questions #1 and #2 are similar, but they don't use a custom Docker image.
The essence of this question is: do the sandbox limitations on System.Drawing.Common apply also when using a custom Docker image?
For reference, here is the runtime image section from the Dockerfile:
FROM mcr.microsoft.com/azure-functions/dotnet:2.0
#libgdiplus, libc6-dev and ttf-mscorefonts are for the aspose library
# sources.list manipulation and eula acceptance stuff is for ttf-mscorefonts
RUN sed -i "s/main/main contrib/g" /etc/apt/sources.list \
&& echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections \
&& apt-get update \
&& apt-get install -y --no-install-recommends libgdiplus libc6-dev ttf-mscorefonts-installer
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
Update: Running the same PDF manipulation code in a .Net Core web app in the Azure Functions docker image works. This indicates that the problem lies within the Azure Functions runtime.
Here's the example snippet to add to the previously mentioned Dockerfile to make it run a Web App instead:
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT [ "dotnet", "/app/WebApiProjectName.dll" ]