Sicos1977 / ChromiumHtmlToPdf

Convert HTML to PDF with a Chromium based browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does ChromeHtmlToPdf work with Azure Function v4 + .net 6.0?

edward0802 opened this issue · comments

commented

It should work on .net 6.0 but I have no idea if it works with Azure function v4 ... never ever tested that.

Thanks for the answer, It works properly on windows (.net 6 + azure func v4) but in Linux (Debian 11 bullseye) in docker, it fails.

This is my Dockerfile:
`FROM mcr.microsoft.com/dotnet/sdk:6.0 AS installer-env

ARG FEED_ACCESSTOKEN

WORKDIR /function
COPY . .
RUN chmod +x generate_nuget_config.sh &&
./generate_nuget_config.sh

RUN cd /function/src/AzureFunctions &&
mkdir -p /home/site/wwwroot &&
dotnet publish *.csproj --output /home/site/wwwroot &&
rm -rf /function/nuget.config

FROM mcr.microsoft.com/azure-functions/dotnet:4.0
ENV ServiceBusWriteConnection=${ServiceBusReadConnection}
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update && apt-get install -y chromium
RUN apt-get update && apt-get install -y
apt-transport-https
ca-certificates
curl
gnupg
--no-install-recommends
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list

RUN apt-get update && apt-get install -y google-chrome-stable
--no-install-recommends
&& apt-get purge --auto-remove -y curl gnupg
&& rm -rf /var/lib/apt/lists/*

RUN apt-get update &&
apt-get install -y unzip &&
wget https://chromedriver.storage.googleapis.com/2.41/chromedriver_linux64.zip &&
unzip chromedriver_linux64.zip &&
mv chromedriver /usr/bin && rm -f chromedriver_linux64.zip

RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
COPY /fonts /usr/share/fonts
RUN fc-cache -f -v

EXPOSE 80Also i added --no-sandbox argumentargs.Add("--no-sandbox");`

I run my app sucessfully but when i check /home/site/wwwroot/publish/bin folder i didn't see any dll related to ChromeHtmlToPdf library
image

Also i didn't find chromedriver in /usr/bin
image

When I try to trigger my azure function I get 'Object reference not set to an instance of an object.' error without any extra info

I use ChromeHtmlToPdf v-2.5.29 in the BLL project that was added to the azure function project.

Can someone help me with this issue, please?

commented

You could look into this issue or otherwise ask him --> #66 or this issue --> #39