It turns out that only the Premium or better Azure Function plan supports running in a container. If you use the Consumption plan, you don't get the option to "Deploy as Container Image". Without this option set (even if all the environment variables are set) it won't correctly start the container, and it'll error with "0 functions found". Flip over to a Premium or better plan, set the option "Deploy as Container Image" and everything works just fine.
Azure Functions in a Container: 0 functions found

How do I get Azure Functions to correctly run my .NET function from a container?
Example repo that reproduces the concern: https://github.com/robrich/azure-functions
Public image built from the code above: robrich.azurecr.io/func1:0cc2c12e5da12319faf50750783063130c4daf35-main
I've run the tutorial from https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-custom-container using the Azure Functions
section. This builds the v4 C# function and the Dockerfile in Visual Studio 2022.
I provision the Azure Function in the portal using the Consumption plan and choose .NET Isolated 8.0
as my stack.
I've set WEBSITES_ENABLE_APP_SERVICE_STORAGE=false
to ensure /home/site/wwwroot
isn't overwritten with blank content. See also:
- 0 function loaded error in Azure app service custom docker container
- Running Azure Functions locally shows 1 function found but 0 loaded and it doesn't work
- https://github.com/Azure/azure-functions-docker/issues/642
Then I follow the instructions from https://github.com/Azure/functions-container-action to add the GitHub Actions build and deploy. See https://github.com/robrich/azure-functions/blob/main/.github/workflows/dotnet-build.yaml
When I build and deploy the container locally, the function runs just fine, and I get this console output:
info: Host.Startup[
info: Host.Startup[326]
Reading functions metadata (Custom)
info: Host.Startup[327]
0 functions found (Custom)
info: Host.Startup[315]
1 functions loaded
info: Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher[0]
Worker process started and initialized.
info: Host.Startup[0]
Generating 1 job function(s)
info: Host.Startup[0]
Found the following functions:
Host.Functions.Function1
info: Host.Startup[
When GitHub Actions deploys the container runs in Azure, the function is unavailable and I get this console output:
2024-12-07
2024-12-07T02:29:47Z [Information] Loading functions metadata
2024-12-07T02:29:47Z [Information] Reading functions metadata (Custom)
2024-12-07T02:29:47Z [Information] 0 functions found (Custom)
2024-12-07T02:29:47Z [Information] 0 functions loaded
2024-12-07
How do I get Azure Functions to correctly run my .NET function from a container?
2 answers
Sort by: Most helpful
-
-
Khadeer Ali 3,905 Reputation points Microsoft External Staff
2024-12-12T11:28:48.03+00:00 I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer .
Issue: When deploying an Azure Function from a custom container using the Consumption plan, the function runs locally but fails to start in Azure, resulting in the error message: "0 functions found."
Solution: It turns out that only the Premium or higher Azure Function plan supports running in a container. If you use the Consumption plan, the option to "Deploy as Container Image" is unavailable. Without this option enabled, even with all environment variables properly set, the container will not start correctly, leading to the "0 functions found" error.
To resolve this issue:
- Switch to a Premium or better plan for your Azure Function.
- Ensure the "Deploy as Container Image" option is selected when configuring your function.
Once these steps are followed, the function should run successfully in Azure.
If you have any other questions or are still encountering issues, please let me know.
Thank you again for your time and patience throughout this issue.
Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.
If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.