Azure / Azure/azure-functions-host
Azure Function - Linux Docker - Dotnet SDK
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
Hello,
I am trying to have a `dotnet 8.0` application run on Azure through an Azure Function.
The current work that the function does requires to be done as a containerized application.
Here is how it is currently built:
```
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
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"
```
The image is pushed on a private Azure Container Registry.
When running the function locally, everything works fine with `docker run -p 8080:80 -it .azurecr.io/platform-docsaver`
The Azure function is deployed using the following terraform:
```yaml
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 = ".azurecr.io"
image_name = "docsaver"
image_tag = "latest"
}
}
ftps_state = "FtpsOnly"
always_on = var.always_on
}
# bunch of other configuration
}
```
Now the fun part is that the dotnet application does not run because for whatever reason, the dotnet sdk 8.0 is not found/installed WHILE IT IS EXPLICITLY INSTALLED in the Dockerfile (because even that does not seem to solve the issue with the whole Azure Function on Linux that you incorrectly provide):

Can someone explain WHY this is not working AS IT SHOULD? Can you finally update the SDK version to be 8.0 INSTEAD of 6.0.36 because it is fucking awful?
Contributor guide
Research direction
Start by comparing the Dockerfile's Azure Functions base image and installed .NET SDK with the Terraform site_config application_stack shown in the report. Review the Azure Function container startup output, including the linked image, and compare it with the locally working docker run command. Done means identifying why the deployed container cannot find the expected SDK and whether a repository change is needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, docker, terraform
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100