Azure Functions in a Container: 0 functions found

Rob Richardson 5 Reputation points MVP
2024-12-09T16:16:09.9533333+00:00

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:

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?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,540 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,340 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Rob Richardson 5 Reputation points MVP
    2024-12-11T00:57:32.8666667+00:00

    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.

    0 comments No comments

  2. Khadeer Ali 3,905 Reputation points Microsoft External Staff
    2024-12-12T11:28:48.03+00:00

    Hi Rob Richardson

    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:

    1. Switch to a Premium or better plan for your Azure Function.
    2. 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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.