For one of our clients, based on the following blog post, we had to setup a Docker based Azure Function to run puppeteer-sharp. We are trying to run that specific process with the following specifications:
- Deployed on Azure as an
Azure Function(the azure service plan is setup to use Linux as the base OS) - It is built with the following
Dockerfile(and runs perfectly fine locally)
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS installer-env
COPY ./Platform.Core /src/dotnet-function-app/Platform.Core
COPY ./Platform.Infrastructure /src/dotnet-function-app/Platform.Infrastructure
COPY ./Platform.UseCases /src/dotnet-function-app/Platform.UseCases
COPY ./services/Platform.Docsaver /src/dotnet-function-app/services/Platform.Docsaver
RUN cd /src/dotnet-function-app/services/Platform.Docsaver && \
mkdir -p /home/site/wwwroot && \
dotnet publish Platform.Docsaver.csproj --output /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
RUN apt-get update && apt-get -f install && apt-get -y install wget gnupg2 apt-utils
RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN rm packages-microsoft-prod.deb
RUN apt-get update && apt-get install -y dotnet-runtime-8.0 dotnet-sdk-8.0
RUN wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt-get update \
&& apt-get install -y /tmp/chrome.deb --no-install-recommends --allow-downgrades fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
&& rm /tmp/chrome.deb
ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-stable"
ENV IsInDocker "true"
- We deploy it with the following
terraform(as it is what is used by our customer)
resource "azurerm_linux_function_app" "function_app_linux" {
name = "fa-${var.customer_abbreviation}-${var.environment}-${var.project}-${var.function_name}"
location = var.location
resource_group_name = var.resource_group
service_plan_id = var.service_plan
storage_account_name = azurerm_storage_account.storage_account.name
storage_account_access_key = azurerm_storage_account.storage_account.primary_access_key
functions_extension_version = var.appversion
site_config {
application_stack {
docker {
registry_url = "<container-registry>.azurecr.io"
image_name = "docsaver"
image_tag = "v1.0.0"
}
}
ftps_state = "FtpsOnly"
always_on = var.always_on
}
app_settings = {
AzureWebJobsDashboard = var.AzureWebJobsDashboard
AzureWebJobsStorage = var.AzureWebJobsStorage
FUNCTIONS_WORKER_RUNTIME = var.FUNCTIONS_WORKER_RUNTIME
WEBSITE_RUN_FROM_PACKAGE = var.WEBSITE_RUN_FROM_PACKAGE
StorageAccount = var.StorageAccount
WEBSITE_TIME_ZONE = var.WEBSITE_TIME_ZONEs
}
identity {
type = "SystemAssigned"
}
lifecycle {
ignore_changes = [
# virtual_network_subnet_id needs to be ignored when using azurerm_app_service_virtual_network_swift_connection https://github.com/hashicorp/terraform-provider-azurerm/issues/17930
# app settings being ignored are secret valuse which cannot be detected by terraform
tags,
virtual_network_subnet_id,
app_settings["APPINSIGHTS_INSTRUMENTATIONKEY"],
app_settings["APPLICATIONINSIGHTS_CONNECTION_STRING"],
app_settings["AzureWebJobsDashboard"],
app_settings["AzureWebJobsStorage"],
]
}
}
The current issue is that the Dotnet application does not run, and when using the Azure advanced tools to launch the application directly, it returns the following:

which means that the dotnet runtime is missing (we expect version 8.0 to be present), but for some reason, even if we specifically install it on the image, it is not there.
Any suggestion of anything that we are missing or anything wrong in the configuration?
If we do not use the docker {} configuration part, this does not work with puppeteer, so it is not possible to use something else as the configuration.
We also noticed that, the runtime for the azure function is custom (~4) instead of ~4 (but that is not related to terraform, as it is the same if we create the azure function manually)