Search code examples
c#azure-functionsazure-webjobsazure-webjobssdkazure-functions-runtime

No job functions found. Try making your job classes and methods public


First off, I have looked at the other SO posts with the same error message and none seem to resolve my issue. I have tried many permutations and options. My function builds fine but will not run in the CLI, I get the following cryptic error. The MSFT documentation does not seem to have the answers either.

No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

I am trying to run a timer job and then write a collection of messages to an event hub. What am I missing? I have been fighting this for hours.

Function:

    [FunctionName("CreateData")]
    public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer,
        [EventHub("murraytest", Connection = "evingest")] IAsyncCollector<string> myeventhub,
        TraceWriter log)
    {
        await myeventhub.AddAsync("data1");
        await myeventhub.AddAsync("data2");
        await myeventhub.AddAsync("data3");

        log.Info($"COMPLETED: {DateTime.Now}");
    }

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "Eventhub": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "",
    "evingest": "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=LtcqBLT5VWjg0dGMdIvxCcEGs8902010Y6y14iGg="

  }
}

Packages

Nuget

function.json - is missing any eventhub bindings!

{
  "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "timerTrigger",
      "schedule": "0 */5 * * * *",
      "useMonitor": true,
      "runOnStartup": false,
      "name": "myTimer"
    }
  ],
  "disabled": false,
  "scriptFile": "..\\bin\\AzFuncs.dll",
  "entryPoint": "AzFuncs.Function1.Run"
}

Solution

  • UPDATE

    My post below is coming up 5 years old. While it is still relevant, there are other answers here you should "and" together with mine. (Esp the net 5 FunctionName).

    Original

    Another gotcha I found especially if you are converting from another project or version.

    In the VS csproj file, make sure AzureFunctionsVersion is present

    <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
        <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    </PropertyGroup>
    ...etc
    

    the tooling adds this automatically but not added if you are modifying a project where this was missing. Hope this helps you save the 3 hours it cost me :-).