How to deploy Azure function (.net 8 isolated worker process) in aks cluster

Patrick Koorevaar 6 Reputation points
2024-03-05T12:41:08.27+00:00

I created a Service Bus trigger function with .Net 8 and the isolated worker model.

It is running fine locally (on my Windows laptop)

However when I deploy it to my AKS cluster the memory usage keeps on growing (starts around 140 MB and after some hours it reaches the limit of 192 MB and is then restarted), like if there is a memory leak. Every time when the trigger is activated around 1MB is added to the memory usage. Even when I commented out my code (the handling of the message) I see this behavior. I don't have this problem with my other Service Bus trigger azure functions which I deployed in the cluster, which uses . NET 6 and the in-process model.

I am using the standard (generated by the template in Visual Studio) Dockerfile which uses the following image:
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 AS base

I am using the latest libs:
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />

<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.17.0" />

<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />

<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />

<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />

<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />

<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />

Thanks

Edit:

I forgot to mention that the service is used in combination with KEDA, but until now only one instance is running.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,405 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,472 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,902 questions
{count} votes