Search code examples
c#azure-functionsdockerfileazure-aks.net-8.0

Migrate from .NET 6 to .NET 8 In-process Azure function in AKS


I'm trying to migrate all my in-process azure functions apps to .NET 8 in Azure kubernetes cluster. The functions runs as docker containers. I have also changed the docker files to target 8.0 SDK.

Locally u need to set the FUNCTIONS_INPROC_NET8_ENABLED to 1, Do u need to set some parameter running in AKS?

All apps works locally for me!

I have updated the Targetframework to .NET 8 and update the Function.SDK to 4.4.1. I have then deployed the applications to our DEV environment, i can see that the apps are starting, but when our Frontend tries to call our different APIs, nothing happens, cant even see an error in the function logs. It's quite recently that they released .NET 8 for in-process functions, so I haven't found any good answers on the subject, so I think I'll ask a question and see if others have the same problem. As I said, it's a bit difficult to troubleshoot because I don't get any error logs or anything.

EDIT: I have tested to rollback all apps to .NET 6 and the function SDK to 4.2.0 and then everything start working again so, does .NET 8 work in AKS? or am i missing some config?

Dockerfile:

FROM mcr.microsoft.com/azure-functions/dotnet:4 AS base
WORKDIR /home/site/wwwroot
EXPOSE 8080
ENV ASPNETCORE_URLS=http://*:8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["ProjectName/ProjectName.csproj", "ProjectName/"]
RUN dotnet restore "ProjectName/ProjectName.csproj"
COPY . .
WORKDIR "/src/ProjectName"
RUN dotnet build "ProjectName.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ProjectName.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

EDIT 2: So i managed to solve the problem. I saw that Microsoft had updated the dockerfile for .NET 8 now, changing this line in the dockerfile solved the problem:

FROM mcr.microsoft.com/azure-functions/dotnet:4-dotnet8.0 AS base

Solution

  • So i managed to solve the problem. I saw that Microsoft had updated the dockerfile for .NET 8 now, changing this line in the dockerfile solved the problem:

    FROM mcr.microsoft.com/azure-functions/dotnet:4-dotnet8.0 AS base