Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 441 forks source link

Function in .Net 8 with in-process model failed to startup in Linux container hosted in AKS #10413

Open anupamk1506 opened 2 months ago

anupamk1506 commented 2 months ago

Is your question related to a specific version? If so, please specify: .NET 8 dotnet-inproc linux Container AKS V4

What language does your question apply to? (e.g. C#, JavaScript, Java, All) C#

Question

We migrated the function to .Net 8 with in-process model using the steps mentioned in https://github.com/Azure/azure-functions-host/issues/9951#issuecomment-2174365098.

It is working fine locally on windows machine with Visual studio. We deployed function in AKS with Linux containers using base image mcr.microsoft.com/azure-functions/dotnet:4.

The function is not working in AKS, we checked the pod logs where it shows it has issue with Startup.

image

We checked the application insights, where is shows : Error configuring services in an external startup class. Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

image

We tried downgrading the version and removing the package 'Microsoft.Extensions.Configuration.Abstractions. However it didn’t work. And got the same error.

The NuGet package used are : image

image

We have added keys in local.setting.json and appsetting.json

image

The same function is working in .Net6 InProc and we are facing this issue after .Net8 upgrade to InProc.

This is blocker to us for our .Net 8 upgrade. Need help in resolving/investigation of this issue.

Let me know if you need more information.

Thanks!

kshyju commented 2 months ago

What is the HOST_VERSION environment variable value you are seeing in your container?

anupamk1506 commented 2 months ago

What is the HOST_VERSION environment variable value you are seeing in your container?

@kshyju Currently we haven't set the HOST_VERSION environment variable in docker file

image

Do we require to add this for inproc function ? As per this thread https://github.com/Azure/azure-functions-docker/issues/1105 HOST_VERSION should be set for isolated function for Open telemetry. Please suggest.

kshyju commented 2 months ago

The base image sets it. Run the container and you should be able to inspect the env variables.

anupamk1506 commented 2 months ago

The base image sets it. Run the container and you should be able to inspect the env variables.

@kshyju , yes, I can this variable is being set when we build the docker image

image

At Pod level, I can see the variable HOST_VERSION is properly set

image

Do we need to override this? Please suggest

kshyju commented 2 months ago

I believe you are using an incorrect base image. @satvu Could you please point the image which supports in-proc net8 ?

anupamk1506 commented 2 months ago

I believe you are using an incorrect base image. @satvu Could you please point the image which supports in-proc net8 ?

@kshyju Thanks for update. @satvu Can you please share image which supports in-proc net8?

kshyju commented 2 months ago

Please try mcr.microsoft.com/azure-functions/dotnet:4-dotnet8.0

KlausHans commented 4 days ago

I have the same problem and unfortunately mcr.microsoft.com/azure-functions/dotnet:4-dotnet8.0 didn't solved it for me. Any other ideas?