[Fixed] "No job functions found" Try making your job classes and methods public in AzureFunctions


I created a .NET 6 Azure Function App project and followed the isolated process. However, when attempting to run my Azure Functions using `dotnet`, I encountered the error message: "No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.), make sure you've called the registration method for the extension(s) in your startup code (e.g. `builder.AddAzureStorage()`, `builder.AddServiceBus()`, `builder.AddTimers()`, etc.)." I'm attempting to run a timer job that sends email notifications to all users.
Solution:
 

We encountered this issue when converting a .NET Core 5  Azure Function to .NET 7. Following the migration guide provided by Microsoft, we updated our project according to the instructions.

However, when attempting to run the function locally, we received the error message instructing us to ensure that we've called the registration method for the extension(s) in our startup code (e.g., `builder.AddAzureStorage()`, `builder.AddServiceBus()`, `builder.AddTimers()`, etc.).

After investigation, we found that updating the `FUNCTIONS_WORKER_RUNTIME` value in the `local.settings.json` file from `"dotnet"` to `"dotnet-isolated"` resolved the issue.

`local.settings.json` file:

  {
    "IsEncrypted": false,
    "Values": {
      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
      "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
      
    }
  }
  

For anyone facing a similar issue, ensure that your Azure Function is registered as a V4 function and that the `FUNCTIONS_WORKER_RUNTIME` is set appropriately. 

We encountered the same error message ".Net 6 FunctionApp: No job functions found. Try making your job classes and methods public" while working on a .NET 6 FunctionApp project and error typically occurs when Azure Functions can't find any public classes or methods that serve as job functions for the application.

We need to ensure that our job classes and methods are public.

  1. Open the class file that contains the Azure Function and ensure that both the class containing the function and the function itself are declared as public.

    public class Taskscheduler
    {
        [Function("CreateJob")]
        public async Task RunAsync([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, FunctionContext context)
        {
            //logic here
        }
    }
          
  2. Make sure and check that the function method is correctly attributed with the [Function] attribute, specifying the function name and Make sure that the project is correctly configured to use Azure Functions also check that the necessary NuGet packages are installed, and the functions folder contains the necessary files like host.json and local.settings.json.

2

In our case, we encountered an issue with the local.settings.json file. we had added an extra double quote and comma character to the file, which was causing the error. 

One more thing if you're upgrading from in-process to .NET Isolated, you may encounter issues, one common solution is to delete both the bin and obj folders. 

3 Check local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}
In above example, the local.settings.json file contains configuration settings for an Azure Functions project running locally,  The Values section contains key-value pairs representing various settings. AzureWebJobsStorage specifies the connection string for Azure Storage. 

In this case, it's set to use the Azure Storage Emulator with UseDevelopmentStorage=true. FUNCTIONS_WORKER_RUNTIME specifies the runtime for the Azure Functions worker. 

Here, we have set to use the dotnet runtime and make sure that the contents of your local.settings.json file correct.
4

We resolved the issue by changing the "FUNCTIONS_WORKER_RUNTIME": "dotnet" setting to "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated".

it's important to note that when using Azure Functions in .NET 5 or later versions, we need to replace the [FunctionName("SendEmail")] attribute with [Function("SendEmail")]


5

In our case we found that running dotnet clean resolved it for us , this command cleans the build temporary files from the project, and resolving any inconsistencies or conflicts that may be causing the error.

Additionally, we discovered that mistakenly including local.settings.json in the .gitignore file can also lead to similar issues.

Another thing to check is whether we're running the command from the correct directory, run command from the root of the functions project.